-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Pretty print pattern type values with transmute if they don't satisfy their pattern #136235
base: master
Are you sure you want to change the base?
Conversation
Some changes occurred to the CTFE machinery cc @rust-lang/wg-const-eval |
cx.validate_operand( | ||
&allocated.into(), | ||
/*recursive*/ false, | ||
/*reset_provenance_and_padding*/ false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
existing, but maybe use enums instead of bool + comments :3
ace8014
to
291f59b
Compare
compiler/rustc_const_eval/src/util/validate_scalar_in_layout.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_const_eval/src/util/validate_scalar_in_layout.rs
Outdated
Show resolved
Hide resolved
291f59b
to
7ec029c
Compare
let typing_env = ty::TypingEnv::fully_monomorphized(); | ||
let mut cx = InterpCx::new(tcx.tcx, tcx.span, typing_env, machine); | ||
|
||
let Ok(layout) = cx.layout_of(ty) else { return false }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reporting false
in case of a layout computation error seems odd? This is almost certainly a bug, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could just unwrap it and we'll do it properly when we can write a test for it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works for me.
@matthiaskrgr heads-up if you see this ICE, please ping us and thanks in advance for generating a test case. :)
r=me with the unwrap. |
7ec029c
to
9e50c77
Compare
…fy their pattern
9e50c77
to
5465770
Compare
@bors r=RalfJung |
Instead of printing
0_u32 is 1..
, we now print the default fallback rendering that we also use for invalid bools, chars, ...:{transmute(0x00000000): (u32) is 1..=}
.These cases can occur in mir dumps when const prop propagates a constant across a safety check that would prevent the actually UB value from existing. That's fine though, as it's dead code and we always need to allow UB in dead code.
follow-up to #136176
cc @compiler-errors @scottmcm
r? @RalfJung because of the interpreter changes