Make a fake body to store typeck results for global_asm
This commit is contained in:
parent
37060aae13
commit
6ba39f7dc7
37 changed files with 244 additions and 232 deletions
|
@ -126,6 +126,11 @@ pub(crate) enum DefiningTy<'tcx> {
|
|||
/// The MIR represents an inline const. The signature has no inputs and a
|
||||
/// single return value found via `InlineConstArgs::ty`.
|
||||
InlineConst(DefId, GenericArgsRef<'tcx>),
|
||||
|
||||
// Fake body for a global asm. Not particularly useful or interesting,
|
||||
// but we need it so we can properly store the typeck results of the asm
|
||||
// operands, which aren't associated with a body otherwise.
|
||||
GlobalAsm(DefId),
|
||||
}
|
||||
|
||||
impl<'tcx> DefiningTy<'tcx> {
|
||||
|
@ -138,9 +143,10 @@ impl<'tcx> DefiningTy<'tcx> {
|
|||
DefiningTy::Closure(_, args) => args.as_closure().upvar_tys(),
|
||||
DefiningTy::CoroutineClosure(_, args) => args.as_coroutine_closure().upvar_tys(),
|
||||
DefiningTy::Coroutine(_, args) => args.as_coroutine().upvar_tys(),
|
||||
DefiningTy::FnDef(..) | DefiningTy::Const(..) | DefiningTy::InlineConst(..) => {
|
||||
ty::List::empty()
|
||||
}
|
||||
DefiningTy::FnDef(..)
|
||||
| DefiningTy::Const(..)
|
||||
| DefiningTy::InlineConst(..)
|
||||
| DefiningTy::GlobalAsm(_) => ty::List::empty(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,7 +158,10 @@ impl<'tcx> DefiningTy<'tcx> {
|
|||
DefiningTy::Closure(..)
|
||||
| DefiningTy::CoroutineClosure(..)
|
||||
| DefiningTy::Coroutine(..) => 1,
|
||||
DefiningTy::FnDef(..) | DefiningTy::Const(..) | DefiningTy::InlineConst(..) => 0,
|
||||
DefiningTy::FnDef(..)
|
||||
| DefiningTy::Const(..)
|
||||
| DefiningTy::InlineConst(..)
|
||||
| DefiningTy::GlobalAsm(_) => 0,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,7 +180,8 @@ impl<'tcx> DefiningTy<'tcx> {
|
|||
| DefiningTy::Coroutine(def_id, ..)
|
||||
| DefiningTy::FnDef(def_id, ..)
|
||||
| DefiningTy::Const(def_id, ..)
|
||||
| DefiningTy::InlineConst(def_id, ..) => def_id,
|
||||
| DefiningTy::InlineConst(def_id, ..)
|
||||
| DefiningTy::GlobalAsm(def_id) => def_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -411,6 +421,7 @@ impl<'tcx> UniversalRegions<'tcx> {
|
|||
tcx.def_path_str_with_args(def_id, args),
|
||||
));
|
||||
}
|
||||
DefiningTy::GlobalAsm(_) => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -633,6 +644,8 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
|
|||
DefiningTy::InlineConst(self.mir_def.to_def_id(), args)
|
||||
}
|
||||
}
|
||||
|
||||
BodyOwnerKind::GlobalAsm => DefiningTy::GlobalAsm(self.mir_def.to_def_id()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -666,6 +679,8 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
|
|||
}
|
||||
|
||||
DefiningTy::FnDef(_, args) | DefiningTy::Const(_, args) => args,
|
||||
|
||||
DefiningTy::GlobalAsm(_) => ty::List::empty(),
|
||||
};
|
||||
|
||||
let global_mapping = iter::once((tcx.lifetimes.re_static, fr_static));
|
||||
|
@ -802,6 +817,10 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
|
|||
let ty = args.as_inline_const().ty();
|
||||
ty::Binder::dummy(tcx.mk_type_list(&[ty]))
|
||||
}
|
||||
|
||||
DefiningTy::GlobalAsm(def_id) => {
|
||||
ty::Binder::dummy(tcx.mk_type_list(&[tcx.type_of(def_id).instantiate_identity()]))
|
||||
}
|
||||
};
|
||||
|
||||
// FIXME(#129952): We probably want a more principled approach here.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue