File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -167,10 +167,13 @@ extern "C" {
167167}
168168
169169impl < Dyn : ?Sized > DynMetadata < Dyn > {
170- /// One of the things that rustc_middle does with this being a lang item is
171- /// give it `FieldsShape::Primitive`, which means that as far as codegen can
172- /// tell, it *is* a reference, and thus doesn't have any fields.
173- /// That means we can't use field access, and have to transmute it instead.
170+ /// When `DynMetadata` appears as the metadata field of a wide pointer, the rustc_middle layout
171+ /// computation does magic and the resulting layout is *not* a `FieldsShape::Aggregate`, instead
172+ /// it is a `FieldsShape::Primitive`. This means that the same type can have different layout
173+ /// depending on whether it appears as the metadata field of a wide pointer or as a stand-alone
174+ /// type, which understandably confuses codegen and leads to ICEs when trying to project to a
175+ /// field of `DynMetadata`. To work around that issue, we use `transmute` instead of using a
176+ /// field projection.
174177 #[ inline]
175178 fn vtable_ptr ( self ) -> * const VTable {
176179 // SAFETY: this layout assumption is hard-coded into the compiler.
You can’t perform that action at this time.
0 commit comments