@@ -126,6 +126,11 @@ pub(crate) enum DefiningTy<'tcx> {
126126 /// The MIR represents an inline const. The signature has no inputs and a
127127 /// single return value found via `InlineConstArgs::ty`.
128128 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 ) ,
129134}
130135
131136impl < ' tcx > DefiningTy < ' tcx > {
@@ -138,9 +143,10 @@ impl<'tcx> DefiningTy<'tcx> {
138143 DefiningTy :: Closure ( _, args) => args. as_closure ( ) . upvar_tys ( ) ,
139144 DefiningTy :: CoroutineClosure ( _, args) => args. as_coroutine_closure ( ) . upvar_tys ( ) ,
140145 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 ( ) ,
144150 }
145151 }
146152
@@ -152,7 +158,10 @@ impl<'tcx> DefiningTy<'tcx> {
152158 DefiningTy :: Closure ( ..)
153159 | DefiningTy :: CoroutineClosure ( ..)
154160 | DefiningTy :: Coroutine ( ..) => 1 ,
155- DefiningTy :: FnDef ( ..) | DefiningTy :: Const ( ..) | DefiningTy :: InlineConst ( ..) => 0 ,
161+ DefiningTy :: FnDef ( ..)
162+ | DefiningTy :: Const ( ..)
163+ | DefiningTy :: InlineConst ( ..)
164+ | DefiningTy :: GlobalAsm ( _) => 0 ,
156165 }
157166 }
158167
@@ -171,7 +180,8 @@ impl<'tcx> DefiningTy<'tcx> {
171180 | DefiningTy :: Coroutine ( def_id, ..)
172181 | DefiningTy :: FnDef ( def_id, ..)
173182 | DefiningTy :: Const ( def_id, ..)
174- | DefiningTy :: InlineConst ( def_id, ..) => def_id,
183+ | DefiningTy :: InlineConst ( def_id, ..)
184+ | DefiningTy :: GlobalAsm ( def_id) => def_id,
175185 }
176186 }
177187}
@@ -411,6 +421,7 @@ impl<'tcx> UniversalRegions<'tcx> {
411421 tcx. def_path_str_with_args( def_id, args) ,
412422 ) ) ;
413423 }
424+ DefiningTy :: GlobalAsm ( _) => unreachable ! ( ) ,
414425 }
415426 }
416427
@@ -633,6 +644,8 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
633644 DefiningTy :: InlineConst ( self . mir_def . to_def_id ( ) , args)
634645 }
635646 }
647+
648+ BodyOwnerKind :: GlobalAsm => DefiningTy :: GlobalAsm ( self . mir_def . to_def_id ( ) ) ,
636649 }
637650 }
638651
@@ -666,6 +679,8 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
666679 }
667680
668681 DefiningTy :: FnDef ( _, args) | DefiningTy :: Const ( _, args) => args,
682+
683+ DefiningTy :: GlobalAsm ( _) => ty:: List :: empty ( ) ,
669684 } ;
670685
671686 let global_mapping = iter:: once ( ( tcx. lifetimes . re_static , fr_static) ) ;
@@ -802,6 +817,10 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
802817 let ty = args. as_inline_const ( ) . ty ( ) ;
803818 ty:: Binder :: dummy ( tcx. mk_type_list ( & [ ty] ) )
804819 }
820+
821+ DefiningTy :: GlobalAsm ( def_id) => {
822+ ty:: Binder :: dummy ( tcx. mk_type_list ( & [ tcx. type_of ( def_id) . instantiate_identity ( ) ] ) )
823+ }
805824 } ;
806825
807826 // FIXME(#129952): We probably want a more principled approach here.
0 commit comments