Skip to content

Commit 04c0058

Browse files
Properly support thin ptrs that are only thin due to their param-env in asm macro
1 parent bb029a1 commit 04c0058

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

Diff for: compiler/rustc_hir_analysis/src/check/intrinsicck.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,12 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
3333
pub fn new(
3434
tcx: TyCtxt<'tcx>,
3535
def_id: LocalDefId,
36+
typing_env: ty::TypingEnv<'tcx>,
3637
get_operand_ty: impl Fn(&hir::Expr<'tcx>) -> Ty<'tcx> + 'a,
3738
) -> Self {
3839
InlineAsmCtxt {
3940
tcx,
40-
typing_env: ty::TypingEnv {
41-
typing_mode: ty::TypingMode::non_body_analysis(),
42-
param_env: ty::ParamEnv::empty(),
43-
},
41+
typing_env,
4442
target_features: tcx.asm_target_features(def_id),
4543
expr_ty: Box::new(get_operand_ty),
4644
}

Diff for: compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
110110
self.tcx.erase_regions(ty)
111111
}
112112
};
113-
InlineAsmCtxt::new(self.tcx, enclosing_id, expr_ty).check_asm(asm);
113+
InlineAsmCtxt::new(self.tcx, enclosing_id, self.typing_env(self.param_env), expr_ty)
114+
.check_asm(asm);
114115
}
115116
}
116117

Diff for: tests/ui/asm/conditionally-sized-ptr.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ check-pass
2+
//@ needs-asm-support
3+
4+
use std::arch::asm;
5+
6+
fn _f<T>(p: *mut T) {
7+
unsafe {
8+
asm!("/* {} */", in(reg) p);
9+
}
10+
}
11+
12+
fn main() {}

0 commit comments

Comments
 (0)