@@ -125,6 +125,11 @@ pub(crate) enum DefiningTy<'tcx> {
125125 /// The MIR represents an inline const. The signature has no inputs and a
126126 /// single return value found via `InlineConstArgs::ty`.
127127 InlineConst ( DefId , GenericArgsRef < ' tcx > ) ,
128+
129+ // Fake body for a global asm. Not particularly useful or interesting,
130+ // but we need it so we can properly store the typeck results of the asm
131+ // operands, which aren't associated with a body otherwise.
132+ GlobalAsm ( DefId ) ,
128133}
129134
130135impl < ' tcx > DefiningTy < ' tcx > {
@@ -137,9 +142,10 @@ impl<'tcx> DefiningTy<'tcx> {
137142 DefiningTy :: Closure ( _, args) => args. as_closure ( ) . upvar_tys ( ) ,
138143 DefiningTy :: CoroutineClosure ( _, args) => args. as_coroutine_closure ( ) . upvar_tys ( ) ,
139144 DefiningTy :: Coroutine ( _, args) => args. as_coroutine ( ) . upvar_tys ( ) ,
140- DefiningTy :: FnDef ( ..) | DefiningTy :: Const ( ..) | DefiningTy :: InlineConst ( ..) => {
141- ty:: List :: empty ( )
142- }
145+ DefiningTy :: FnDef ( ..)
146+ | DefiningTy :: Const ( ..)
147+ | DefiningTy :: InlineConst ( ..)
148+ | DefiningTy :: GlobalAsm ( _) => ty:: List :: empty ( ) ,
143149 }
144150 }
145151
@@ -151,7 +157,10 @@ impl<'tcx> DefiningTy<'tcx> {
151157 DefiningTy :: Closure ( ..)
152158 | DefiningTy :: CoroutineClosure ( ..)
153159 | DefiningTy :: Coroutine ( ..) => 1 ,
154- DefiningTy :: FnDef ( ..) | DefiningTy :: Const ( ..) | DefiningTy :: InlineConst ( ..) => 0 ,
160+ DefiningTy :: FnDef ( ..)
161+ | DefiningTy :: Const ( ..)
162+ | DefiningTy :: InlineConst ( ..)
163+ | DefiningTy :: GlobalAsm ( _) => 0 ,
155164 }
156165 }
157166
@@ -170,7 +179,8 @@ impl<'tcx> DefiningTy<'tcx> {
170179 | DefiningTy :: Coroutine ( def_id, ..)
171180 | DefiningTy :: FnDef ( def_id, ..)
172181 | DefiningTy :: Const ( def_id, ..)
173- | DefiningTy :: InlineConst ( def_id, ..) => def_id,
182+ | DefiningTy :: InlineConst ( def_id, ..)
183+ | DefiningTy :: GlobalAsm ( def_id) => def_id,
174184 }
175185 }
176186}
@@ -410,6 +420,7 @@ impl<'tcx> UniversalRegions<'tcx> {
410420 tcx. def_path_str_with_args( def_id, args) ,
411421 ) ) ;
412422 }
423+ DefiningTy :: GlobalAsm ( _) => unreachable ! ( ) ,
413424 }
414425 }
415426
@@ -629,6 +640,8 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
629640 DefiningTy :: InlineConst ( self . mir_def . to_def_id ( ) , args)
630641 }
631642 }
643+
644+ BodyOwnerKind :: GlobalAsm => DefiningTy :: GlobalAsm ( self . mir_def . to_def_id ( ) ) ,
632645 }
633646 }
634647
@@ -662,6 +675,8 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
662675 }
663676
664677 DefiningTy :: FnDef ( _, args) | DefiningTy :: Const ( _, args) => args,
678+
679+ DefiningTy :: GlobalAsm ( _) => ty:: List :: empty ( ) ,
665680 } ;
666681
667682 let global_mapping = iter:: once ( ( tcx. lifetimes . re_static , fr_static) ) ;
@@ -798,6 +813,10 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
798813 let ty = args. as_inline_const ( ) . ty ( ) ;
799814 ty:: Binder :: dummy ( tcx. mk_type_list ( & [ ty] ) )
800815 }
816+
817+ DefiningTy :: GlobalAsm ( def_id) => {
818+ ty:: Binder :: dummy ( tcx. mk_type_list ( & [ tcx. type_of ( def_id) . instantiate_identity ( ) ] ) )
819+ }
801820 } ;
802821
803822 // FIXME(#129952): We probably want a more principled approach here.
0 commit comments