about summary refs log tree commit diff
path: root/tests/ui/asm
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2025-02-23 22:54:36 +0000
committerMichael Goulet <michael@errs.io>2025-03-06 17:34:17 +0000
commitc867b8f11dbf0be397ba9b5c898fde95f8d5ea6c (patch)
treec891942b163e1f81eefc87db4d32d3fe64b79e96 /tests/ui/asm
parent30f168ef811aec63124eac677e14699baa9395bd (diff)
downloadrust-c867b8f11dbf0be397ba9b5c898fde95f8d5ea6c.tar.gz
rust-c867b8f11dbf0be397ba9b5c898fde95f8d5ea6c.zip
Construct MIR error body for global_asm correctly
Diffstat (limited to 'tests/ui/asm')
-rw-r--r--tests/ui/asm/global-asm-with-error.rs11
-rw-r--r--tests/ui/asm/global-asm-with-error.stderr9
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/ui/asm/global-asm-with-error.rs b/tests/ui/asm/global-asm-with-error.rs
new file mode 100644
index 00000000000..c2253e3cb87
--- /dev/null
+++ b/tests/ui/asm/global-asm-with-error.rs
@@ -0,0 +1,11 @@
+// Ensure that we don't ICE when constructing the fake MIR body for a global
+// asm when the body has errors. See #137470.
+
+//@ needs-asm-support
+
+use std::arch::global_asm;
+
+global_asm!("/* {} */", sym a);
+//~^ ERROR cannot find value `a` in this scope
+
+fn main() {}
diff --git a/tests/ui/asm/global-asm-with-error.stderr b/tests/ui/asm/global-asm-with-error.stderr
new file mode 100644
index 00000000000..6c07a9f020d
--- /dev/null
+++ b/tests/ui/asm/global-asm-with-error.stderr
@@ -0,0 +1,9 @@
+error[E0425]: cannot find value `a` in this scope
+  --> $DIR/global-asm-with-error.rs:6:29
+   |
+LL | global_asm!("/* {} */", sym a);
+   |                             ^ not found in this scope
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0425`.