1
Fork 0

Properly support thin ptrs that are only thin due to their param-env in asm macro

This commit is contained in:
Michael Goulet 2025-02-24 16:12:43 +00:00
parent bb029a1d3f
commit 04c00585c3
3 changed files with 16 additions and 5 deletions

View file

@ -33,14 +33,12 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
pub fn new(
tcx: TyCtxt<'tcx>,
def_id: LocalDefId,
typing_env: ty::TypingEnv<'tcx>,
get_operand_ty: impl Fn(&hir::Expr<'tcx>) -> Ty<'tcx> + 'a,
) -> Self {
InlineAsmCtxt {
tcx,
typing_env: ty::TypingEnv {
typing_mode: ty::TypingMode::non_body_analysis(),
param_env: ty::ParamEnv::empty(),
},
typing_env,
target_features: tcx.asm_target_features(def_id),
expr_ty: Box::new(get_operand_ty),
}

View file

@ -110,7 +110,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.tcx.erase_regions(ty)
}
};
InlineAsmCtxt::new(self.tcx, enclosing_id, expr_ty).check_asm(asm);
InlineAsmCtxt::new(self.tcx, enclosing_id, self.typing_env(self.param_env), expr_ty)
.check_asm(asm);
}
}

View file

@ -0,0 +1,12 @@
//@ check-pass
//@ needs-asm-support
use std::arch::asm;
fn _f<T>(p: *mut T) {
unsafe {
asm!("/* {} */", in(reg) p);
}
}
fn main() {}