-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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/mir: const value enums with no variants #73442
pretty/mir: const value enums with no variants #73442
Conversation
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
r? @oli-obk |
The changes from indexing to |
db77648
to
8ca3c74
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
I'm not able to reproduce this locally after rebasing on master, any ideas @oli-obk? |
8ca3c74
to
750efc6
Compare
@bors r+ |
📌 Commit 750efc6e1d60df527f541f01b561747813c4585b has been approved by |
This comment has been minimized.
This comment has been minimized.
This commit modifies the pretty printer and const eval in the MIR so that `destructure_const` (used in `pretty_print_const_value`) can handle enums with no variants (or types containing enums with no variants). Signed-off-by: David Wood <david@davidtw.co>
750efc6
to
6fa7dc6
Compare
r=me with CI passing |
@bors r=oli-obk |
📌 Commit 6fa7dc6 has been approved by |
…arth Rollup of 16 pull requests Successful merges: - rust-lang#71420 (Specialization is unsound) - rust-lang#71899 (Refactor `try_find` a little) - rust-lang#72689 (add str to common types) - rust-lang#72791 (update coerce docs and unify relevant tests) - rust-lang#72934 (forbid mutable references in all constant contexts except for const-fns) - rust-lang#73027 (Make `need_type_info_err` more conservative) - rust-lang#73347 (Diagnose use of incompatible sanitizers) - rust-lang#73359 (shim.rs: avoid creating `Call` terminators calling `Self`) - rust-lang#73399 (Clean up E0668 explanation) - rust-lang#73436 (Clean up E0670 explanation) - rust-lang#73440 (Add src/librustdoc as an alias for src/tools/rustdoc) - rust-lang#73442 (pretty/mir: const value enums with no variants) - rust-lang#73452 (Unify region variables when projecting associated types) - rust-lang#73458 (Use alloc::Layout in DroplessArena API) - rust-lang#73484 (Update the doc for std::prelude to the correct behavior) - rust-lang#73506 (Bump Rustfmt and RLS) Failed merges: r? @ghost
ty::Adt(def, substs) if def.variants.is_empty() => { | ||
p!(print_value_path(def.did, substs)); | ||
} |
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 don't think this should ever be reached? This sort of thing should be an evaluation error, surely?
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 don’t know about an evaluation error, but this definitely gets reached.
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.
we use the pretty printer from within the miri engine and the const evaluator does not validate that every local is always valid, only miri does this.
Fixes #72181.
This PR modifies the pretty printer and const eval in the MIR so that
destructure_const
(used inpretty_print_const_value
) can handle enums with no variants (or types containing enums with no variants).I'm not convinced that this is the correct approach, folks more familiar with
destructure_const
would be able to say - happy to adjust the PR. Looking throughdestructure_const
and the functions that it invokes, it didn't seem like it was written to handle zero-variant-enums - I assume that case is handled earlier in some way sodestructure_const
doesn't need to under normal circumstances. It didn't seem like it would be straightforward to makedestructure_const
handle this case in a first-class-feeling way (e.g. adding aVariants::None
variant), so this PR makes some minimal changes to avoid ICEs.