-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Support pretty printing of invalid constants #94020
Conversation
Some changes occured to the CTFE / Miri engine cc @rust-lang/miri |
r? @oli-obk (rust-highfive has picked a reviewer for you, use r? to override) |
@bors r+ rollup |
📌 Commit a8bc3b3c353b479f8063f41bb620e3611a3e2fa3 has been approved by |
📌 Commit ae5c039c11ca544f331202d847fc55ab4a587a02 has been approved by |
…askrgr Rollup of 5 pull requests Successful merges: - rust-lang#93899 (Describe VecDeque with more consistent names) - rust-lang#93949 (Add basic platform support to library/{panic_}unwind for m68k) - rust-lang#93999 (suggest using raw strings when invalid escapes appear in literals) - rust-lang#94001 (llvm: migrate to new parameter-bearing uwtable attr) - rust-lang#94014 (Move transmute_undefined_repr back to nursery) Failed merges: - rust-lang#94020 (Support pretty printing of invalid constants) r? `@ghost` `@rustbot` modify labels: rollup
discriminant(_2) = 0; // scope 0 at $DIR/invalid_constant.rs:16:7: 16:11 | ||
- _3 = discriminant(_2); // scope 1 at $DIR/invalid_constant.rs:16:5: 16:12 | ||
- switchInt(move _3) -> [0_isize: bb3, otherwise: bb2]; // scope 1 at $DIR/invalid_constant.rs:16:5: 16:12 | ||
+ _3 = const 0_isize; // scope 1 at $DIR/invalid_constant.rs:16:5: 16:12 |
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.
Why does this change?
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's just the optimization changing the mir. This is a diff of a diff
bb2: { | ||
- _4 = ((_2 as Some).0: std::option::Option<()>); // scope 1 at $DIR/invalid_constant.rs:16:5: 16:12 | ||
- _1 = _4; // scope 2 at $DIR/invalid_constant.rs:16:5: 16:12 | ||
+ _4 = const ConstValue(Scalar(0x02): Option::<()>); // scope 1 at $DIR/invalid_constant.rs:16:5: 16:12 |
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.
const ConstValue
seems somewhat redundant, if we always have that const
prefix maybe we should make this just const Scalar(0x02): Option::<()>
? Or maybe also somehow indicate that this value is invalid and a "fallback" printing was used?
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.
Dropped ConstValue
part, matching the following fall back format instead of the preceding verbose one.
@bors r- the output could be adjusted a bit |
Make it possible to pretty print invalid constants by introducing a fallible variant of `destructure_const` and falling back to debug formatting when it fails.
@bors r+ |
📌 Commit 92d20c4 has been approved by |
Support pretty printing of invalid constants Make it possible to pretty print invalid constants by introducing a fallible variant of `destructure_const` and falling back to debug formatting when it fails. Closes rust-lang#93688.
…askrgr Rollup of 10 pull requests Successful merges: - rust-lang#92366 (Resolve concern of `derive_default_enum`) - rust-lang#93382 (Add a bit more padding in search box) - rust-lang#93962 (Make [u8]::cmp implementation branchless) - rust-lang#94015 (rustdoc --check option documentation) - rust-lang#94017 (Clarify confusing UB statement in MIR) - rust-lang#94020 (Support pretty printing of invalid constants) - rust-lang#94027 (Update browser UI test version) - rust-lang#94037 (Fix inconsistent symbol mangling with -Zverbose) - rust-lang#94045 (Update books) - rust-lang#94054 (:arrow_up: rust-analyzer) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Make it possible to pretty print invalid constants by introducing a
fallible variant of
destructure_const
and falling back to debugformatting when it fails.
Closes #93688.