File tree 2 files changed +23
-0
lines changed
compiler/rustc_mir_transform/src
2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,11 @@ fn escaping_locals<'tcx>(
70
70
// Exclude #[repr(simd)] types so that they are not de-optimized into an array
71
71
return true ;
72
72
}
73
+ if Some ( def. did ( ) ) == tcx. lang_items ( ) . dyn_metadata ( ) {
74
+ // codegen wants to see the `DynMetadata<T>`,
75
+ // not the inner reference-to-opaque-type.
76
+ return true ;
77
+ }
73
78
// We already excluded unions and enums, so this ADT must have one variant
74
79
let variant = def. variant ( FIRST_VARIANT ) ;
75
80
if variant. fields . len ( ) > 1 {
Original file line number Diff line number Diff line change
1
+ //@ compile-flags: -Zmir-opt-level=5 -Zvalidate-mir
2
+
3
+ #![ feature( ptr_metadata) ]
4
+
5
+ // Regression for <https://github.com/rust-lang/rust/issues/125506>,
6
+ // which failed because of SRoA would project into `DynMetadata`.
7
+
8
+ trait Foo { }
9
+
10
+ struct Bar ;
11
+
12
+ impl Foo for Bar { }
13
+
14
+ fn main ( ) {
15
+ let a: * mut dyn Foo = & mut Bar ;
16
+
17
+ let d = a. to_raw_parts ( ) . 0 as usize ;
18
+ }
You can’t perform that action at this time.
0 commit comments