-
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
Fix pretty printing of enums without variants #94093
Conversation
Huh... why does read_discriminant succeed when there are no variants, that seems like a bug? |
It has to succeed on types without discriminants. This is exposed to safe code via https://doc.rust-lang.org/nightly/std/mem/fn.discriminant.html for any type Requiring full validity didn't work, due to #91029. |
66c08bd
to
863c822
Compare
(For checking what changed in a PR, it'd be easier if you don't rebase onto newer master -- right now the force-push-diff that GH generates is useless if I want to see what you changed in the latest version of this PR, compared to a previous one. During review, I think it is best if force-pushes are avoided entirely, since GH is not great at keeping track of multiple revisions of a PR, and can lose diffs if there are multiple consecutive force-pushes. Our highfive bot also at least used to recommend that contributors do not force-push until review is done; not sure if it still does that.) |
So basically we have two invariants that we would like to maintain but cannot both maintain:
I am not sure which invariant is less painful to break. This PR is necessary since we recently switched from breaking the former to breaking the latter. |
@bors r+ rollup |
📌 Commit 863c8229aa1be2c4fe5f91139a25419d1f1a72b5 has been approved by |
☔ The latest upstream changes (presumably #94148) made this pull request unmergeable. Please resolve the merge conflicts. |
92d20c4 removed no-variants special case from try_destructure_const with expectation that this case would be handled gracefully when read_discriminant returns an error. Alas in that case read_discriminant succeeds while returning a non-existing variant, so the special case is still necessary.
863c822
to
c2da477
Compare
@bors r+ |
📌 Commit c2da477 has been approved by |
Fix pretty printing of enums without variants 92d20c4 removed no-variants special case from `try_destructure_const` with expectation that this case would be handled gracefully when `read_discriminant` returns an error. Alas in that case `read_discriminant` succeeds while returning a non-existing variant, so the special case is still necessary. Fixes rust-lang#94073. r? `@oli-obk`
Fix pretty printing of enums without variants 92d20c4 removed no-variants special case from `try_destructure_const` with expectation that this case would be handled gracefully when `read_discriminant` returns an error. Alas in that case `read_discriminant` succeeds while returning a non-existing variant, so the special case is still necessary. Fixes rust-lang#94073. r? ``@oli-obk``
Fix pretty printing of enums without variants 92d20c4 removed no-variants special case from `try_destructure_const` with expectation that this case would be handled gracefully when `read_discriminant` returns an error. Alas in that case `read_discriminant` succeeds while returning a non-existing variant, so the special case is still necessary. Fixes rust-lang#94073. r? ```@oli-obk```
…askrgr Rollup of 14 pull requests Successful merges: - rust-lang#93580 (Stabilize pin_static_ref.) - rust-lang#93639 (Release notes for 1.59) - rust-lang#93686 (core: Implement ASCII trim functions on byte slices) - rust-lang#94002 (rustdoc: Avoid duplicating macros in sidebar) - rust-lang#94019 (removing architecture requirements for RustyHermit) - rust-lang#94023 (adapt static-nobundle test to use llvm-nm) - rust-lang#94091 (Fix rustdoc const computed value) - rust-lang#94093 (Fix pretty printing of enums without variants) - rust-lang#94097 (Add module-level docs for `rustc_middle::query`) - rust-lang#94112 (Optimize char_try_from_u32) - rust-lang#94113 (document rustc_middle::mir::Field) - rust-lang#94122 (Fix miniz_oxide types showing up in std docs) - rust-lang#94142 (rustc_typeck: adopt let else in more places) - rust-lang#94146 (Adopt let else in more places) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
92d20c4 removed no-variants special case from
try_destructure_const
with expectation that this case would be handled gracefully whenread_discriminant
returns an error.Alas in that case
read_discriminant
succeeds while returning a non-existing variant, so the special case is still necessary.Fixes #94073.
r? @oli-obk