diff options
| author | bors <bors@rust-lang.org> | 2024-05-24 08:53:27 +0000 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-05-24 08:53:27 +0000 | 
| commit | 464987730ab36e3456ba57c53965372989382deb (patch) | |
| tree | 4572720248cde25b6ed1cf95cc0c246eeb281033 /compiler/rustc_resolve/src/errors.rs | |
| parent | 7c547894c76efe9303caa3108754674c39bd901d (diff) | |
| parent | d83f3ca8ca2d20eadf92a135a1a4b65ca91a24f6 (diff) | |
| download | rust-464987730ab36e3456ba57c53965372989382deb.tar.gz rust-464987730ab36e3456ba57c53965372989382deb.zip | |
Auto merge of #125479 - scottmcm:validate-vtable-projections, r=Nilstrieb
Validate the special layout restriction on `DynMetadata`
If you look at <https://stdrs.dev/nightly/x86_64-unknown-linux-gnu/std/ptr/struct.DynMetadata.html>, you'd think that `DynMetadata` is a struct with fields.
But it's actually not, because the lang item is special-cased in rustc_middle layout:
https://github.com/rust-lang/rust/blob/7601adcc764d42c9f2984082b49948af652df986/compiler/rustc_middle/src/ty/layout.rs#L861-L864
That explains the very confusing codegen ICEs I was getting in https://github.com/rust-lang/rust/pull/124251#issuecomment-2128543265
> Tried to extract_field 0 from primitive OperandRef(Immediate((ptr:  %5 = load ptr, ptr %4, align 8, !nonnull !3, !align !5, !noundef !3)) @ TyAndLayout { ty: DynMetadata<dyn Callsite>, layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Primitive, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes) } })
because there was a `Field` projection despite the layout clearly saying it's [`Primitive`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_target/abi/enum.FieldsShape.html#variant.Primitive).
Thus this PR updates the MIR validator to check for such a projection, and changes `libcore` to not ever emit any projections into `DynMetadata`, just to transmute the whole thing when it wants a pointer.
Diffstat (limited to 'compiler/rustc_resolve/src/errors.rs')
0 files changed, 0 insertions, 0 deletions
