move fn is_item_raw
to TypingEnv
This commit is contained in:
parent
89b6885529
commit
948cec0fad
60 changed files with 181 additions and 168 deletions
|
@ -15,7 +15,7 @@ use rustc_target::asm::{
|
|||
|
||||
pub struct InlineAsmCtxt<'a, 'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
typing_env: ty::TypingEnv<'tcx>,
|
||||
get_operand_ty: Box<dyn Fn(&'tcx hir::Expr<'tcx>) -> Ty<'tcx> + 'a>,
|
||||
}
|
||||
|
||||
|
@ -23,24 +23,29 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||
pub fn new_global_asm(tcx: TyCtxt<'tcx>) -> Self {
|
||||
InlineAsmCtxt {
|
||||
tcx,
|
||||
param_env: ty::ParamEnv::empty(),
|
||||
typing_env: ty::TypingEnv {
|
||||
typing_mode: ty::TypingMode::non_body_analysis(),
|
||||
param_env: ty::ParamEnv::empty(),
|
||||
},
|
||||
get_operand_ty: Box::new(|e| bug!("asm operand in global asm: {e:?}")),
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME(#132279): This likely causes us to incorrectly handle opaque types in their
|
||||
// defining scope.
|
||||
pub fn new_in_fn(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
typing_env: ty::TypingEnv<'tcx>,
|
||||
get_operand_ty: impl Fn(&'tcx hir::Expr<'tcx>) -> Ty<'tcx> + 'a,
|
||||
) -> Self {
|
||||
InlineAsmCtxt { tcx, param_env, get_operand_ty: Box::new(get_operand_ty) }
|
||||
InlineAsmCtxt { tcx, typing_env, get_operand_ty: Box::new(get_operand_ty) }
|
||||
}
|
||||
|
||||
// FIXME(compiler-errors): This could use `<$ty as Pointee>::Metadata == ()`
|
||||
fn is_thin_ptr_ty(&self, ty: Ty<'tcx>) -> bool {
|
||||
// Type still may have region variables, but `Sized` does not depend
|
||||
// on those, so just erase them before querying.
|
||||
if ty.is_sized(self.tcx, self.param_env) {
|
||||
if ty.is_sized(self.tcx, self.typing_env) {
|
||||
return true;
|
||||
}
|
||||
if let ty::Foreign(..) = ty.kind() {
|
||||
|
@ -171,7 +176,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||
|
||||
// Check that the type implements Copy. The only case where this can
|
||||
// possibly fail is for SIMD types which don't #[derive(Copy)].
|
||||
if !ty.is_copy_modulo_regions(self.tcx, self.param_env) {
|
||||
if !ty.is_copy_modulo_regions(self.tcx, self.typing_env) {
|
||||
let msg = "arguments for inline assembly must be copyable";
|
||||
self.tcx
|
||||
.dcx()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue