From cac7c127a270f90cc2ab3cb8179bf6bb2745a783 Mon Sep 17 00:00:00 2001 From: nxya Date: Mon, 14 Aug 2023 14:07:28 -0400 Subject: [PATCH] fixed *const [type error] does not implement the Copy trait --- compiler/rustc_hir_analysis/src/check/intrinsicck.rs | 2 +- tests/ui/asm/issue-113788.rs | 7 +++++++ tests/ui/asm/issue-113788.stderr | 9 +++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/ui/asm/issue-113788.rs create mode 100644 tests/ui/asm/issue-113788.stderr diff --git a/compiler/rustc_hir_analysis/src/check/intrinsicck.rs b/compiler/rustc_hir_analysis/src/check/intrinsicck.rs index b0dd5e5787dc2..945953edd5aec 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsicck.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsicck.rs @@ -68,7 +68,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> { let asm_ty = match *ty.kind() { // `!` is allowed for input but not for output (issue #87802) ty::Never if is_input => return None, - ty::Error(_) => return None, + _ if ty.references_error() => return None, ty::Int(IntTy::I8) | ty::Uint(UintTy::U8) => Some(InlineAsmType::I8), ty::Int(IntTy::I16) | ty::Uint(UintTy::U16) => Some(InlineAsmType::I16), ty::Int(IntTy::I32) | ty::Uint(UintTy::U32) => Some(InlineAsmType::I32), diff --git a/tests/ui/asm/issue-113788.rs b/tests/ui/asm/issue-113788.rs new file mode 100644 index 0000000000000..903b444767f6a --- /dev/null +++ b/tests/ui/asm/issue-113788.rs @@ -0,0 +1,7 @@ +// test that "error: arguments for inline assembly must be copyable" doesn't show up in this code +// needs-asm-support +// only-x86_64 +fn main() { + let peb: *const PEB; //~ ERROR cannot find type `PEB` in this scope [E0412] + unsafe { std::arch::asm!("mov {0}, fs:[0x30]", out(reg) peb); } +} diff --git a/tests/ui/asm/issue-113788.stderr b/tests/ui/asm/issue-113788.stderr new file mode 100644 index 0000000000000..f8e65b6f53817 --- /dev/null +++ b/tests/ui/asm/issue-113788.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `PEB` in this scope + --> $DIR/issue-113788.rs:5:21 + | +LL | let peb: *const PEB; + | ^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`.