-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Handle dyn* coercions for values that are represented with OperandValue::Ref
#104694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -774,12 +774,7 @@ where | |||
TyMaybeWithLayout::Ty(tcx.mk_mut_ptr(tcx.types.unit)) | ||||
} else if i == 1 { | ||||
// FIXME(dyn-star) same FIXME as above applies here too | ||||
TyMaybeWithLayout::Ty( | ||||
tcx.mk_imm_ref( | ||||
tcx.lifetimes.re_static, | ||||
tcx.mk_array(tcx.types.usize, 3), | ||||
), | ||||
) | ||||
TyMaybeWithLayout::Ty(tcx.mk_imm_ptr(tcx.mk_array(tcx.types.usize, 3))) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is necessary because if we represent the vtable as a reference, then CTFE wants to validate the pointer. However, the vtable is represented by Alternatively, we could fix this instead I guess:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't happen, validity checking should stop at the Did you rebase? #107728 fixed some issues with dyn* handling in the validity check. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is based off of a rebased master. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strange. Then CTFE should never see this type. What's the error you are getting otherwise, and for which code? Ideally with RUSTC_CTFE_BACKTRACE=1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Why? Here we write the vtable to the second part of the scalar pair. So we're trying to write the vtable allocation pointer to a place of type There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, that's where this comes from. But during CTFE we don't do validation on writes... this should only affect Miri. Still a problem though. However why wouldn't this also be a problem for vtables in wide pointers? I'm also worried using a raw pointer type here could have bad side-effects, like losing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It's probably because we don't explicitly split up the write for |
||||
} else { | ||||
bug!("no field {i} on dyn*") | ||||
} | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#![feature(dyn_star)] | ||
#![allow(incomplete_features)] | ||
|
||
use std::fmt::Debug; | ||
|
||
#[derive(Debug)] | ||
#[repr(C)] | ||
pub struct Foo(usize); | ||
|
||
fn main() { | ||
let x = Foo(1) as dyn* Debug; | ||
assert_eq!(format!("{x:?}"), "Foo(1)"); | ||
} |
Uh oh!
There was an error while loading. Please reload this page.