about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_target/src/asm/mod.rs14
-rw-r--r--src/test/rustdoc/asm-foreign.rs (renamed from src/test/rustdoc-ui/asm-foreign.rs)7
-rw-r--r--src/test/rustdoc/asm-foreign2.rs11
-rw-r--r--src/test/ui/issues/issue-82869.rs23
-rw-r--r--src/test/ui/issues/issue-82869.stderr24
5 files changed, 69 insertions, 10 deletions
diff --git a/compiler/rustc_target/src/asm/mod.rs b/compiler/rustc_target/src/asm/mod.rs
index 1d0013bcd2c..a09c87b3ec2 100644
--- a/compiler/rustc_target/src/asm/mod.rs
+++ b/compiler/rustc_target/src/asm/mod.rs
@@ -313,7 +313,7 @@ impl InlineAsmReg {
             Self::RiscV(r) => r.emit(out, arch, modifier),
             Self::Hexagon(r) => r.emit(out, arch, modifier),
             Self::Mips(r) => r.emit(out, arch, modifier),
-            Self::Err => unreachable!(),
+            Self::Err => unreachable!("Use of InlineAsmReg::Err"),
         }
     }
 
@@ -325,7 +325,7 @@ impl InlineAsmReg {
             Self::RiscV(_) => cb(self),
             Self::Hexagon(r) => r.overlapping_regs(|r| cb(Self::Hexagon(r))),
             Self::Mips(_) => cb(self),
-            Self::Err => unreachable!(),
+            Self::Err => unreachable!("Use of InlineAsmReg::Err"),
         }
     }
 }
@@ -386,7 +386,7 @@ impl InlineAsmRegClass {
             Self::Mips(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::Mips),
             Self::SpirV(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::SpirV),
             Self::Wasm(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::Wasm),
-            Self::Err => unreachable!(),
+            Self::Err => unreachable!("Use of InlineAsmRegClass::Err"),
         }
     }
 
@@ -411,7 +411,7 @@ impl InlineAsmRegClass {
             Self::Mips(r) => r.suggest_modifier(arch, ty),
             Self::SpirV(r) => r.suggest_modifier(arch, ty),
             Self::Wasm(r) => r.suggest_modifier(arch, ty),
-            Self::Err => unreachable!(),
+            Self::Err => unreachable!("Use of InlineAsmRegClass::Err"),
         }
     }
 
@@ -432,7 +432,7 @@ impl InlineAsmRegClass {
             Self::Mips(r) => r.default_modifier(arch),
             Self::SpirV(r) => r.default_modifier(arch),
             Self::Wasm(r) => r.default_modifier(arch),
-            Self::Err => unreachable!(),
+            Self::Err => unreachable!("Use of InlineAsmRegClass::Err"),
         }
     }
 
@@ -452,7 +452,7 @@ impl InlineAsmRegClass {
             Self::Mips(r) => r.supported_types(arch),
             Self::SpirV(r) => r.supported_types(arch),
             Self::Wasm(r) => r.supported_types(arch),
-            Self::Err => unreachable!(),
+            Self::Err => unreachable!("Use of InlineAsmRegClass::Err"),
         }
     }
 
@@ -489,7 +489,7 @@ impl InlineAsmRegClass {
             Self::Mips(r) => r.valid_modifiers(arch),
             Self::SpirV(r) => r.valid_modifiers(arch),
             Self::Wasm(r) => r.valid_modifiers(arch),
-            Self::Err => unreachable!(),
+            Self::Err => unreachable!("Use of InlineAsmRegClass::Err"),
         }
     }
 }
diff --git a/src/test/rustdoc-ui/asm-foreign.rs b/src/test/rustdoc/asm-foreign.rs
index dfd73147417..570ed043dd9 100644
--- a/src/test/rustdoc-ui/asm-foreign.rs
+++ b/src/test/rustdoc/asm-foreign.rs
@@ -1,9 +1,9 @@
-// check-pass
 // Make sure rustdoc accepts asm! for a foreign architecture.
 
 #![feature(asm)]
 
-pub unsafe fn aarch64(a: f64, b: f64) {
+// @has asm_foreign/fn.aarch64.html
+pub unsafe fn aarch64(a: f64, b: f64) -> f64 {
     let c;
     asm!("add {:d}, {:d}, d0", out(vreg) c, in(vreg) a, in("d0") {
         || {};
@@ -12,7 +12,8 @@ pub unsafe fn aarch64(a: f64, b: f64) {
     c
 }
 
-pub unsafe fn x86(a: f64, b: f64) {
+// @has asm_foreign/fn.x86.html
+pub unsafe fn x86(a: f64, b: f64) -> f64 {
     let c;
     asm!("addsd {}, {}, xmm0", out(xmm_reg) c, in(xmm_reg) a, in("xmm0") b);
     c
diff --git a/src/test/rustdoc/asm-foreign2.rs b/src/test/rustdoc/asm-foreign2.rs
new file mode 100644
index 00000000000..34e313e7eac
--- /dev/null
+++ b/src/test/rustdoc/asm-foreign2.rs
@@ -0,0 +1,11 @@
+// only-aarch64
+// Make sure rustdoc accepts options(att_syntax) asm! on non-x86 targets.
+
+#![feature(asm)]
+
+// @has asm_foreign2/fn.x86.html
+pub unsafe fn x86(x: i64) -> i64 {
+    let y;
+    asm!("movq {}, {}", in(reg) x, out(reg) y, options(att_syntax));
+    y
+}
diff --git a/src/test/ui/issues/issue-82869.rs b/src/test/ui/issues/issue-82869.rs
new file mode 100644
index 00000000000..a8e688cbe1f
--- /dev/null
+++ b/src/test/ui/issues/issue-82869.rs
@@ -0,0 +1,23 @@
+// only-x86_64
+// Make sure rustc doesn't ICE on asm! for a foreign architecture.
+
+#![feature(asm)]
+#![crate_type = "rlib"]
+
+pub unsafe fn aarch64(a: f64, b: f64) -> f64 {
+    let c;
+    asm!("add {:d}, {:d}, d0", out(vreg) c, in(vreg) a, in("d0") {
+        || {};
+        b
+    });
+    //~^^^^ invalid register class
+    //~^^^^^ invalid register class
+    //~^^^^^^ invalid register
+    c
+}
+
+pub unsafe fn x86(a: f64, b: f64) -> f64 {
+    let c;
+    asm!("addsd {}, {}, xmm0", out(xmm_reg) c, in(xmm_reg) a, in("xmm0") b);
+    c
+}
diff --git a/src/test/ui/issues/issue-82869.stderr b/src/test/ui/issues/issue-82869.stderr
new file mode 100644
index 00000000000..d05714ea6f2
--- /dev/null
+++ b/src/test/ui/issues/issue-82869.stderr
@@ -0,0 +1,24 @@
+error: invalid register class `vreg`: unknown register class
+  --> $DIR/issue-82869.rs:9:32
+   |
+LL |     asm!("add {:d}, {:d}, d0", out(vreg) c, in(vreg) a, in("d0") {
+   |                                ^^^^^^^^^^^
+
+error: invalid register class `vreg`: unknown register class
+  --> $DIR/issue-82869.rs:9:45
+   |
+LL |     asm!("add {:d}, {:d}, d0", out(vreg) c, in(vreg) a, in("d0") {
+   |                                             ^^^^^^^^^^
+
+error: invalid register `d0`: unknown register
+  --> $DIR/issue-82869.rs:9:57
+   |
+LL |       asm!("add {:d}, {:d}, d0", out(vreg) c, in(vreg) a, in("d0") {
+   |  _________________________________________________________^
+LL | |         || {};
+LL | |         b
+LL | |     });
+   | |_____^
+
+error: aborting due to 3 previous errors
+