Skip to content

Commit 86523e9

Browse files
Rollup merge of rust-lang#97493 - compiler-errors:issue-97490, r=oli-obk
Use `type_is_copy_modulo_regions` check in intrisicck This one canoncalizes region variables correctly, preventing an ICE Fixes rust-lang#97490
2 parents 98b134b + 46d34cc commit 86523e9

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

compiler/rustc_typeck/src/check/intrinsicck.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use rustc_session::lint;
99
use rustc_span::{Span, Symbol, DUMMY_SP};
1010
use rustc_target::abi::{Pointer, VariantIdx};
1111
use rustc_target::asm::{InlineAsmReg, InlineAsmRegClass, InlineAsmRegOrRegClass, InlineAsmType};
12+
use rustc_trait_selection::infer::InferCtxtExt;
1213

1314
use super::FnCtxt;
1415

@@ -210,7 +211,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
210211

211212
// Check that the type implements Copy. The only case where this can
212213
// possibly fail is for SIMD types which don't #[derive(Copy)].
213-
if !ty.is_copy_modulo_regions(self.tcx.at(DUMMY_SP), self.param_env) {
214+
if !self.infcx.type_is_copy_modulo_regions(self.param_env, ty, DUMMY_SP) {
214215
let msg = "arguments for inline assembly must be copyable";
215216
let mut err = self.tcx.sess.struct_span_err(expr.span, msg);
216217
err.note(&format!("`{ty}` does not implement the Copy trait"));

src/test/ui/asm/issue-97490.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// check-pass
2+
// only-x86_64
3+
// needs-asm-support
4+
5+
pub type Yes = extern "sysv64" fn(&'static u8) -> !;
6+
7+
fn main() {
8+
unsafe {
9+
let yes = &6 as *const _ as *const Yes;
10+
core::arch::asm!("call {}", in(reg) yes, options(noreturn));
11+
}
12+
}

0 commit comments

Comments
 (0)