about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-08-14 21:57:51 +0200
committerGitHub <noreply@github.com>2023-08-14 21:57:51 +0200
commit378c2fd644f5e7452f193df696096980e4106c86 (patch)
tree2820292614a66b14016198d47344d3930df2e594
parent106d686e9859fbeb17662dc40cda4525e2e87498 (diff)
parentcac7c127a270f90cc2ab3cb8179bf6bb2745a783 (diff)
downloadrust-378c2fd644f5e7452f193df696096980e4106c86.tar.gz
rust-378c2fd644f5e7452f193df696096980e4106c86.zip
Rollup merge of #114752 - RickleAndMortimer:issue-113788-fix, r=compiler-errors
fixed *const [type error] does not implement the Copy trait

Removes "error: arguments for inline assembly must be copyable" when moving an unknown type

Fixes: #113788
-rw-r--r--compiler/rustc_hir_analysis/src/check/intrinsicck.rs2
-rw-r--r--tests/ui/asm/issue-113788.rs7
-rw-r--r--tests/ui/asm/issue-113788.stderr9
3 files changed, 17 insertions, 1 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/intrinsicck.rs b/compiler/rustc_hir_analysis/src/check/intrinsicck.rs
index b0dd5e5787d..945953edd5a 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 00000000000..903b444767f
--- /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 00000000000..f8e65b6f538
--- /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`.