@@ -126,6 +126,11 @@ pub(crate) enum DefiningTy<'tcx> {
126
126
/// The MIR represents an inline const. The signature has no inputs and a
127
127
/// single return value found via `InlineConstArgs::ty`.
128
128
InlineConst ( DefId , GenericArgsRef < ' tcx > ) ,
129
+
130
+ // Fake body for a global asm. Not particularly useful or interesting,
131
+ // but we need it so we can properly store the typeck results of the asm
132
+ // operands, which aren't associated with a body otherwise.
133
+ GlobalAsm ( DefId ) ,
129
134
}
130
135
131
136
impl < ' tcx > DefiningTy < ' tcx > {
@@ -138,9 +143,10 @@ impl<'tcx> DefiningTy<'tcx> {
138
143
DefiningTy :: Closure ( _, args) => args. as_closure ( ) . upvar_tys ( ) ,
139
144
DefiningTy :: CoroutineClosure ( _, args) => args. as_coroutine_closure ( ) . upvar_tys ( ) ,
140
145
DefiningTy :: Coroutine ( _, args) => args. as_coroutine ( ) . upvar_tys ( ) ,
141
- DefiningTy :: FnDef ( ..) | DefiningTy :: Const ( ..) | DefiningTy :: InlineConst ( ..) => {
142
- ty:: List :: empty ( )
143
- }
146
+ DefiningTy :: FnDef ( ..)
147
+ | DefiningTy :: Const ( ..)
148
+ | DefiningTy :: InlineConst ( ..)
149
+ | DefiningTy :: GlobalAsm ( _) => ty:: List :: empty ( ) ,
144
150
}
145
151
}
146
152
@@ -152,7 +158,10 @@ impl<'tcx> DefiningTy<'tcx> {
152
158
DefiningTy :: Closure ( ..)
153
159
| DefiningTy :: CoroutineClosure ( ..)
154
160
| DefiningTy :: Coroutine ( ..) => 1 ,
155
- DefiningTy :: FnDef ( ..) | DefiningTy :: Const ( ..) | DefiningTy :: InlineConst ( ..) => 0 ,
161
+ DefiningTy :: FnDef ( ..)
162
+ | DefiningTy :: Const ( ..)
163
+ | DefiningTy :: InlineConst ( ..)
164
+ | DefiningTy :: GlobalAsm ( _) => 0 ,
156
165
}
157
166
}
158
167
@@ -171,7 +180,8 @@ impl<'tcx> DefiningTy<'tcx> {
171
180
| DefiningTy :: Coroutine ( def_id, ..)
172
181
| DefiningTy :: FnDef ( def_id, ..)
173
182
| DefiningTy :: Const ( def_id, ..)
174
- | DefiningTy :: InlineConst ( def_id, ..) => def_id,
183
+ | DefiningTy :: InlineConst ( def_id, ..)
184
+ | DefiningTy :: GlobalAsm ( def_id) => def_id,
175
185
}
176
186
}
177
187
}
@@ -411,6 +421,7 @@ impl<'tcx> UniversalRegions<'tcx> {
411
421
tcx. def_path_str_with_args( def_id, args) ,
412
422
) ) ;
413
423
}
424
+ DefiningTy :: GlobalAsm ( _) => unreachable ! ( ) ,
414
425
}
415
426
}
416
427
@@ -633,6 +644,8 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
633
644
DefiningTy :: InlineConst ( self . mir_def . to_def_id ( ) , args)
634
645
}
635
646
}
647
+
648
+ BodyOwnerKind :: GlobalAsm => DefiningTy :: GlobalAsm ( self . mir_def . to_def_id ( ) ) ,
636
649
}
637
650
}
638
651
@@ -666,6 +679,8 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
666
679
}
667
680
668
681
DefiningTy :: FnDef ( _, args) | DefiningTy :: Const ( _, args) => args,
682
+
683
+ DefiningTy :: GlobalAsm ( _) => ty:: List :: empty ( ) ,
669
684
} ;
670
685
671
686
let global_mapping = iter:: once ( ( tcx. lifetimes . re_static , fr_static) ) ;
@@ -802,6 +817,10 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
802
817
let ty = args. as_inline_const ( ) . ty ( ) ;
803
818
ty:: Binder :: dummy ( tcx. mk_type_list ( & [ ty] ) )
804
819
}
820
+
821
+ DefiningTy :: GlobalAsm ( def_id) => {
822
+ ty:: Binder :: dummy ( tcx. mk_type_list ( & [ tcx. type_of ( def_id) . instantiate_identity ( ) ] ) )
823
+ }
805
824
} ;
806
825
807
826
// FIXME(#129952): We probably want a more principled approach here.
0 commit comments