-
Notifications
You must be signed in to change notification settings - Fork 13.3k
improve TagEncoding::Niche docs, sanity check, and UB checks #133681
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
r? @wesleywiser rustbot has assigned @wesleywiser. Use |
The Miri subtree was changed cc @rust-lang/miri Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri Some changes occurred to the CTFE machinery cc @rust-lang/wg-const-eval |
This comment has been minimized.
This comment has been minimized.
The transmute logic seems to be calling |
This comment has been minimized.
This comment has been minimized.
05a4d16
to
3dc9b1b
Compare
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.
r=me with or without the nit 🙂
@bors r+ |
improve TagEncoding::Niche docs, sanity check, and UB checks Turns out the `niche_variants` range can actually contain the `untagged_variant`. We should report this as UB in Miri, so this PR implements that. Also rename `partially_check_layout` to `layout_sanity_check` for better consistency with how similar functions are called in other parts of the compiler. Turns out my adjustments to the transmutation logic also fix rust-lang#126267.
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#132937 (a release operation synchronizes with an acquire operation) - rust-lang#133681 (improve TagEncoding::Niche docs, sanity check, and UB checks) - rust-lang#133726 (Add `core::arch::breakpoint` and test) - rust-lang#133768 (Remove `generic_associated_types_extended` feature gate) - rust-lang#133811 ([AIX] change AIX default codemodel=large) - rust-lang#133812 (Update wasm-component-ld to 0.5.11) - rust-lang#133813 (compiletest: explain that UI tests are expected not to compile by default) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#133681 - RalfJung:niches, r=wesleywiser improve TagEncoding::Niche docs, sanity check, and UB checks Turns out the `niche_variants` range can actually contain the `untagged_variant`. We should report this as UB in Miri, so this PR implements that. Also rename `partially_check_layout` to `layout_sanity_check` for better consistency with how similar functions are called in other parts of the compiler. Turns out my adjustments to the transmutation logic also fix rust-lang#126267.
Variants::Single: do not use invalid VariantIdx for uninhabited enums ~~Stacked on top of rust-lang#133681, only the last commit is new.~~ Currently, `Variants::Single` for an empty enum contains a `VariantIdx` of 0; looking that up in the enum variant list will ICE. That's quite confusing. So let's fix that by adding a new `Variants::Empty` case for types that have 0 variants.
Variants::Single: do not use invalid VariantIdx for uninhabited enums ~~Stacked on top of rust-lang#133681, only the last commit is new.~~ Currently, `Variants::Single` for an empty enum contains a `VariantIdx` of 0; looking that up in the enum variant list will ICE. That's quite confusing. So let's fix that by adding a new `Variants::Empty` case for types that have 0 variants.
Variants::Single: do not use invalid VariantIdx for uninhabited enums ~~Stacked on top of rust-lang#133681, only the last commit is new.~~ Currently, `Variants::Single` for an empty enum contains a `VariantIdx` of 0; looking that up in the enum variant list will ICE. That's quite confusing. So let's fix that by adding a new `Variants::Empty` case for types that have 0 variants.
Variants::Single: do not use invalid VariantIdx for uninhabited enums ~~Stacked on top of rust-lang#133681, only the last commit is new.~~ Currently, `Variants::Single` for an empty enum contains a `VariantIdx` of 0; looking that up in the enum variant list will ICE. That's quite confusing. So let's fix that by adding a new `Variants::Empty` case for types that have 0 variants. try-job: i686-msvc
Variants::Single: do not use invalid VariantIdx for uninhabited enums ~~Stacked on top of rust-lang#133681, only the last commit is new.~~ Currently, `Variants::Single` for an empty enum contains a `VariantIdx` of 0; looking that up in the enum variant list will ICE. That's quite confusing. So let's fix that by adding a new `Variants::Empty` case for types that have 0 variants. try-job: i686-msvc
Rollup merge of rust-lang#133702 - RalfJung:single-variant, r=oli-obk Variants::Single: do not use invalid VariantIdx for uninhabited enums ~~Stacked on top of rust-lang#133681, only the last commit is new.~~ Currently, `Variants::Single` for an empty enum contains a `VariantIdx` of 0; looking that up in the enum variant list will ICE. That's quite confusing. So let's fix that by adding a new `Variants::Empty` case for types that have 0 variants. try-job: i686-msvc
Variants::Single: do not use invalid VariantIdx for uninhabited enums ~~Stacked on top of rust-lang/rust#133681, only the last commit is new.~~ Currently, `Variants::Single` for an empty enum contains a `VariantIdx` of 0; looking that up in the enum variant list will ICE. That's quite confusing. So let's fix that by adding a new `Variants::Empty` case for types that have 0 variants. try-job: i686-msvc
Variants::Single: do not use invalid VariantIdx for uninhabited enums ~~Stacked on top of rust-lang/rust#133681, only the last commit is new.~~ Currently, `Variants::Single` for an empty enum contains a `VariantIdx` of 0; looking that up in the enum variant list will ICE. That's quite confusing. So let's fix that by adding a new `Variants::Empty` case for types that have 0 variants. try-job: i686-msvc
Variants::Single: do not use invalid VariantIdx for uninhabited enums ~~Stacked on top of rust-lang/rust#133681, only the last commit is new.~~ Currently, `Variants::Single` for an empty enum contains a `VariantIdx` of 0; looking that up in the enum variant list will ICE. That's quite confusing. So let's fix that by adding a new `Variants::Empty` case for types that have 0 variants. try-job: i686-msvc
Variants::Single: do not use invalid VariantIdx for uninhabited enums ~~Stacked on top of rust-lang/rust#133681, only the last commit is new.~~ Currently, `Variants::Single` for an empty enum contains a `VariantIdx` of 0; looking that up in the enum variant list will ICE. That's quite confusing. So let's fix that by adding a new `Variants::Empty` case for types that have 0 variants. try-job: i686-msvc
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#132937 (a release operation synchronizes with an acquire operation) - rust-lang#133681 (improve TagEncoding::Niche docs, sanity check, and UB checks) - rust-lang#133726 (Add `core::arch::breakpoint` and test) - rust-lang#133768 (Remove `generic_associated_types_extended` feature gate) - rust-lang#133811 ([AIX] change AIX default codemodel=large) - rust-lang#133812 (Update wasm-component-ld to 0.5.11) - rust-lang#133813 (compiletest: explain that UI tests are expected not to compile by default) r? `@ghost` `@rustbot` modify labels: rollup
Turns out the
niche_variants
range can actually contain theuntagged_variant
. We should report this as UB in Miri, so this PR implements that.Also rename
partially_check_layout
tolayout_sanity_check
for better consistency with how similar functions are called in other parts of the compiler.Turns out my adjustments to the transmutation logic also fix #126267.