const validation: properly ignore zero-sized UnsafeCell#143046
const validation: properly ignore zero-sized UnsafeCell#143046bors merged 2 commits intorust-lang:masterfrom
Conversation
| let zst = self | ||
| .ecx | ||
| .size_and_align_of(&val.meta(), &val.layout)? | ||
| .is_some_and(|(s, _a)| s.bytes() == 0); |
There was a problem hiding this comment.
this seems very footgunny, why do is_zst and size_and_align_of(&val.meta(), &val.layout).is_some_and(|(s, _a)| s.bytes() == 0) differ. When is using is_zst actually correct?
Okay, this is because we're not checking whether the type itself is a ZST, but that the value is a zero-sized. So we don't use is_zst to also handle slices and trait objects. Can you add this as a comment to the code in visit_value?
after that r=me
There was a problem hiding this comment.
When is using is_zst actually correct?
Basically this is must_be_zst, but it can miss types that are only dynamically zero-sized.
d0fce3e to
59e66a6
Compare
|
The Miri subtree was changed cc @rust-lang/miri Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
I also added a 2nd commit making the size_and_align_of APIs in the interpreter a bit nicer. |
59e66a6 to
7de39f5
Compare
|
@bors r=lcnr,oli-obk |
Rollup of 9 pull requests Successful merges: - #139858 (New const traits syntax) - #140809 (Reduce special casing for the panic runtime) - #142730 (suggest declaring modules when file found but module not defined) - #142806 (Normalize before computing ConstArgHasType goal in new solver) - #143046 (const validation: properly ignore zero-sized UnsafeCell) - #143092 (const checks for lifetime-extended temporaries: avoid 'top-level scope' terminology) - #143096 (tag_for_variant: properly pass TypingEnv) - #143104 (hir_analysis: prohibit `dyn PointeeSized`) - #143106 (gce: don't ICE on non-local const) Failed merges: - #143036 (Remove support for `dyn*` from the compiler) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 9 pull requests Successful merges: - rust-lang/rust#139858 (New const traits syntax) - rust-lang/rust#140809 (Reduce special casing for the panic runtime) - rust-lang/rust#142730 (suggest declaring modules when file found but module not defined) - rust-lang/rust#142806 (Normalize before computing ConstArgHasType goal in new solver) - rust-lang/rust#143046 (const validation: properly ignore zero-sized UnsafeCell) - rust-lang/rust#143092 (const checks for lifetime-extended temporaries: avoid 'top-level scope' terminology) - rust-lang/rust#143096 (tag_for_variant: properly pass TypingEnv) - rust-lang/rust#143104 (hir_analysis: prohibit `dyn PointeeSized`) - rust-lang/rust#143106 (gce: don't ICE on non-local const) Failed merges: - rust-lang/rust#143036 (Remove support for `dyn*` from the compiler) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 9 pull requests Successful merges: - rust-lang/rust#139858 (New const traits syntax) - rust-lang/rust#140809 (Reduce special casing for the panic runtime) - rust-lang/rust#142730 (suggest declaring modules when file found but module not defined) - rust-lang/rust#142806 (Normalize before computing ConstArgHasType goal in new solver) - rust-lang/rust#143046 (const validation: properly ignore zero-sized UnsafeCell) - rust-lang/rust#143092 (const checks for lifetime-extended temporaries: avoid 'top-level scope' terminology) - rust-lang/rust#143096 (tag_for_variant: properly pass TypingEnv) - rust-lang/rust#143104 (hir_analysis: prohibit `dyn PointeeSized`) - rust-lang/rust#143106 (gce: don't ICE on non-local const) Failed merges: - rust-lang/rust#143036 (Remove support for `dyn*` from the compiler) r? `@ghost` `@rustbot` modify labels: rollup
Fixes #142948
r? @oli-obk