Skip to content

ice: asm: unreachable #112635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
matthiaskrgr opened this issue Jun 14, 2023 · 2 comments · Fixed by #112683
Closed

ice: asm: unreachable #112635

matthiaskrgr opened this issue Jun 14, 2023 · 2 comments · Fixed by #112683
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Jun 14, 2023

Code

use std::arch::asm;

fn main() {
    unsafe {
        asm!("", clobber_abi(5));
    }
}

Meta

rustc --version --verbose:

rustc 1.72.0-nightly (7b0eac438 2023-06-14)
binary: rustc
commit-hash: 7b0eac438ace0ba305b4633328b00474fbbf5120
commit-date: 2023-06-14
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.5

Error output

-
Backtrace

thread 'rustc' panicked at 'internal error: entered unreachable code', compiler/rustc_builtin_macros/src/asm.rs:411:15
stack backtrace:
   0:     0x7f5376968c41 - std::backtrace_rs::backtrace::libunwind::trace::hd5b7972f789c4974
                               at /rustc/7b0eac438ace0ba305b4633328b00474fbbf5120/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f5376968c41 - std::backtrace_rs::backtrace::trace_unsynchronized::h938f2c39be6402c9
                               at /rustc/7b0eac438ace0ba305b4633328b00474fbbf5120/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f5376968c41 - std::sys_common::backtrace::_print_fmt::hf19df4df321a9f93
                               at /rustc/7b0eac438ace0ba305b4633328b00474fbbf5120/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f5376968c41 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd26317478e51975e
                               at /rustc/7b0eac438ace0ba305b4633328b00474fbbf5120/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f53769c95ff - core::fmt::rt::Argument::fmt::h16c7790b1e3f1543
                               at /rustc/7b0eac438ace0ba305b4633328b00474fbbf5120/library/core/src/fmt/rt.rs:138:9
   5:     0x7f53769c95ff - core::fmt::write::h6ebd457ad24c415a
                               at /rustc/7b0eac438ace0ba305b4633328b00474fbbf5120/library/core/src/fmt/mod.rs:1094:21
   6:     0x7f537695be41 - std::io::Write::write_fmt::h0c198b050bd0b55a
                               at /rustc/7b0eac438ace0ba305b4633328b00474fbbf5120/library/std/src/io/mod.rs:1713:15
   7:     0x7f5376968a55 - std::sys_common::backtrace::_print::h369a7cf325feecb2
                               at /rustc/7b0eac438ace0ba305b4633328b00474fbbf5120/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f5376968a55 - std::sys_common::backtrace::print::h8375e9dd85dcd975
                               at /rustc/7b0eac438ace0ba305b4633328b00474fbbf5120/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f537696b737 - std::panicking::default_hook::{{closure}}::h0cff43e655091646
  10:     0x7f537696b524 - std::panicking::default_hook::h28fa1651a8383aac
                               at /rustc/7b0eac438ace0ba305b4633328b00474fbbf5120/library/std/src/panicking.rs:288:9
  11:     0x7f5379bcd25b - <rustc_driver_impl[d1aa6109471fdd45]::install_ice_hook::{closure#0} as core[9d3b7bf065738f73]::ops::function::FnOnce<(&core[9d3b7bf065738f73]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  12:     0x7f537696be7d - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h5e01b737276d5f55
                               at /rustc/7b0eac438ace0ba305b4633328b00474fbbf5120/library/alloc/src/boxed.rs:1999:9
  13:     0x7f537696be7d - std::panicking::rust_panic_with_hook::hb6b23c86320f793c
                               at /rustc/7b0eac438ace0ba305b4633328b00474fbbf5120/library/std/src/panicking.rs:709:13
  14:     0x7f537696bbd1 - std::panicking::begin_panic_handler::{{closure}}::ha3a4d56807981a5b
                               at /rustc/7b0eac438ace0ba305b4633328b00474fbbf5120/library/std/src/panicking.rs:595:13
  15:     0x7f5376969076 - std::sys_common::backtrace::__rust_end_short_backtrace::hedce57d3aff3f0d4
                               at /rustc/7b0eac438ace0ba305b4633328b00474fbbf5120/library/std/src/sys_common/backtrace.rs:151:18
  16:     0x7f537696b962 - rust_begin_unwind
                               at /rustc/7b0eac438ace0ba305b4633328b00474fbbf5120/library/std/src/panicking.rs:593:5
  17:     0x7f53769c5883 - core::panicking::panic_fmt::hc8c8dc133a503605
                               at /rustc/7b0eac438ace0ba305b4633328b00474fbbf5120/library/core/src/panicking.rs:67:14
  18:     0x7f53769c5913 - core::panicking::panic::hf0e1008480fe1028
                               at /rustc/7b0eac438ace0ba305b4633328b00474fbbf5120/library/core/src/panicking.rs:117:5
  19:     0x7f5379347c59 - rustc_builtin_macros[4236fe0ec7a688d6]::asm::parse_asm_args
  20:     0x7f5379345d96 - rustc_builtin_macros[4236fe0ec7a688d6]::asm::expand_asm
  21:     0x7f537860c888 - <rustc_expand[752c13cf57fc9566]::expand::MacroExpander>::fully_expand_fragment
  22:     0x7f5378b410d7 - <rustc_expand[752c13cf57fc9566]::expand::MacroExpander>::expand_crate
  23:     0x7f5378b40380 - <rustc_session[1ee1d215f1830d4a]::session::Session>::time::<rustc_ast[7b80322a36d12112]::ast::Crate, rustc_interface[acec405c1e433d19]::passes::configure_and_expand::{closure#1}>
  24:     0x7f5378af3698 - rustc_interface[acec405c1e433d19]::passes::resolver_for_lowering
  25:     0x7f53790e3e8a - rustc_query_impl[77c04cfc11717055]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[77c04cfc11717055]::query_impl::resolver_for_lowering::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c2220a5f32aee4a9]::query::erase::Erased<[u8; 8usize]>>
  26:     0x7f53790e3e79 - <rustc_query_impl[77c04cfc11717055]::query_impl::resolver_for_lowering::dynamic_query::{closure#2} as core[9d3b7bf065738f73]::ops::function::FnOnce<(rustc_middle[c2220a5f32aee4a9]::ty::context::TyCtxt, ())>>::call_once
  27:     0x7f53790132fc - rustc_query_system[21afab51dde9dbf3]::query::plumbing::try_execute_query::<rustc_query_impl[77c04cfc11717055]::DynamicConfig<rustc_query_system[21afab51dde9dbf3]::query::caches::SingleCache<rustc_middle[c2220a5f32aee4a9]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[77c04cfc11717055]::plumbing::QueryCtxt, false>
  28:     0x7f537955a865 - rustc_query_impl[77c04cfc11717055]::query_impl::resolver_for_lowering::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7f537924a3e3 - <rustc_middle[c2220a5f32aee4a9]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[d1aa6109471fdd45]::run_compiler::{closure#1}::{closure#2}::{closure#2}, &rustc_data_structures[b715d01ec5ecbd6f]::steal::Steal<(rustc_middle[c2220a5f32aee4a9]::ty::ResolverAstLowering, alloc[a7b65b885799e8e7]::rc::Rc<rustc_ast[7b80322a36d12112]::ast::Crate>)>>
  30:     0x7f5378e3b341 - <rustc_interface[acec405c1e433d19]::interface::Compiler>::enter::<rustc_driver_impl[d1aa6109471fdd45]::run_compiler::{closure#1}::{closure#2}, core[9d3b7bf065738f73]::result::Result<core[9d3b7bf065738f73]::option::Option<rustc_interface[acec405c1e433d19]::queries::Linker>, rustc_span[9591d6886b6f356b]::ErrorGuaranteed>>
  31:     0x7f5378e38fb9 - <scoped_tls[eb9c878293193d5c]::ScopedKey<rustc_span[9591d6886b6f356b]::SessionGlobals>>::set::<rustc_interface[acec405c1e433d19]::interface::run_compiler<core[9d3b7bf065738f73]::result::Result<(), rustc_span[9591d6886b6f356b]::ErrorGuaranteed>, rustc_driver_impl[d1aa6109471fdd45]::run_compiler::{closure#1}>::{closure#0}, core[9d3b7bf065738f73]::result::Result<(), rustc_span[9591d6886b6f356b]::ErrorGuaranteed>>
  32:     0x7f5378e38426 - std[c901bbae7dc26da3]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[acec405c1e433d19]::util::run_in_thread_pool_with_globals<rustc_interface[acec405c1e433d19]::interface::run_compiler<core[9d3b7bf065738f73]::result::Result<(), rustc_span[9591d6886b6f356b]::ErrorGuaranteed>, rustc_driver_impl[d1aa6109471fdd45]::run_compiler::{closure#1}>::{closure#0}, core[9d3b7bf065738f73]::result::Result<(), rustc_span[9591d6886b6f356b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9d3b7bf065738f73]::result::Result<(), rustc_span[9591d6886b6f356b]::ErrorGuaranteed>>
  33:     0x7f5378e381d5 - <<std[c901bbae7dc26da3]::thread::Builder>::spawn_unchecked_<rustc_interface[acec405c1e433d19]::util::run_in_thread_pool_with_globals<rustc_interface[acec405c1e433d19]::interface::run_compiler<core[9d3b7bf065738f73]::result::Result<(), rustc_span[9591d6886b6f356b]::ErrorGuaranteed>, rustc_driver_impl[d1aa6109471fdd45]::run_compiler::{closure#1}>::{closure#0}, core[9d3b7bf065738f73]::result::Result<(), rustc_span[9591d6886b6f356b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9d3b7bf065738f73]::result::Result<(), rustc_span[9591d6886b6f356b]::ErrorGuaranteed>>::{closure#1} as core[9d3b7bf065738f73]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  34:     0x7f53769763a5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf9fefea5dd71558b
                               at /rustc/7b0eac438ace0ba305b4633328b00474fbbf5120/library/alloc/src/boxed.rs:1985:9
  35:     0x7f53769763a5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8c988cde4d28b483
                               at /rustc/7b0eac438ace0ba305b4633328b00474fbbf5120/library/alloc/src/boxed.rs:1985:9
  36:     0x7f53769763a5 - std::sys::unix::thread::Thread::new::thread_start::hac03aed06feb4b93
                               at /rustc/7b0eac438ace0ba305b4633328b00474fbbf5120/library/std/src/sys/unix/thread.rs:108:17
  37:     0x7f537670f44b - <unknown>
  38:     0x7f5376792e40 - <unknown>
  39:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.72.0-nightly (7b0eac438 2023-06-14) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [resolver_for_lowering] getting the resolver for lowering
end of query stack

@matthiaskrgr matthiaskrgr added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Jun 14, 2023
@Jules-Bertholet
Copy link
Contributor

Regressed in 1.58: Godbolt

@asquared31415
Copy link
Contributor

This was #89316, whoops. I can work on this.

@rustbot claim

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jun 16, 2023
…ompiler-errors

fix ICE on specific malformed asm clobber_abi

fixes rust-lang#112635
@bors bors closed this as completed in 7051c84 Jun 17, 2023
Zalathar added a commit to Zalathar/rust that referenced this issue May 19, 2025
…s, r=Amanieu

in `tests/ui/asm/aarch64/parse-error.rs`, only test cases specific to that target

this is more in line with the x86 parse error tests at https://github.com/rust-lang/rust/blob/master/tests/ui/asm/x86_64/x86_64_parse_error.rs. We could at this point use minicore so that these tests run no matter the host target?

`tests/ui/asm/aarch64/parse-error.rs` was mostly a copy of https://github.com/rust-lang/rust/blob/master/tests/ui/asm/parse-error.rs, though a bit out of date. The only aarch64-specific tests are those that talk about register names. Here is a diff between those two files:

```diff
--- <unnamed>
+++ <unnamed>
`@@` -1,4 +1,4 `@@`
-//@ needs-asm-support
+//@ only-aarch64

 use std::arch::{asm, global_asm};

`@@` -36,36 +36,12 `@@`
         //~^ ERROR expected one of
         asm!("{}", options(), const foo);
         //~^ ERROR attempt to use a non-constant value in a constant
-
-        // test that asm!'s clobber_abi doesn't accept non-string literals
-        // see also rust-lang#112635
-        asm!("", clobber_abi());
-        //~^ ERROR at least one abi must be provided
         asm!("", clobber_abi(foo));
         //~^ ERROR expected string literal
         asm!("", clobber_abi("C" foo));
         //~^ ERROR expected one of `)` or `,`, found `foo`
         asm!("", clobber_abi("C", foo));
         //~^ ERROR expected string literal
-        asm!("", clobber_abi(1));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi(()));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi(uwu));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi({}));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi(loop {}));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi(if));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi(do));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi(<));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi(.));
-        //~^ ERROR expected string literal
-
         asm!("{}", clobber_abi("C"), const foo);
         //~^ ERROR attempt to use a non-constant value in a constant
         asm!("", options(), clobber_abi("C"));
`@@` -76,7 +52,15 `@@`
         //~^^ ERROR argument never used
         //~^^^ ERROR attempt to use a non-constant value in a constant
         //~^^^^ ERROR attempt to use a non-constant value in a constant
-
+        asm!("", a = in("x0") foo);
+        //~^ ERROR explicit register arguments cannot have names
+        asm!("{a}", in("x0") foo, a = const bar);
+        //~^ ERROR attempt to use a non-constant value in a constant
+        asm!("{a}", in("x0") foo, a = const bar);
+        //~^ ERROR attempt to use a non-constant value in a constant
+        asm!("{1}", in("x0") foo, const bar);
+        //~^ ERROR positional arguments cannot follow named arguments or explicit register arguments
+        //~^^ ERROR attempt to use a non-constant value in a constant
         asm!("", options(), "");
         //~^ ERROR expected one of
         asm!("{}", in(reg) foo, "{}", out(reg) foo);
`@@` -109,13 +93,11 `@@`
 global_asm!("{}", const(reg) FOO);
 //~^ ERROR expected one of
 global_asm!("", options(FOO));
-//~^ ERROR expected one of `)`, `att_syntax`, or `raw`, found `FOO`
-global_asm!("", options(FOO,));
-//~^ ERROR expected one of `)`, `att_syntax`, or `raw`, found `FOO`
+//~^ ERROR expected one of
 global_asm!("", options(nomem FOO));
-//~^ ERROR expected one of `)` or `,`, found `FOO`
+//~^ ERROR expected one of
 global_asm!("", options(nomem, FOO));
-//~^ ERROR expected one of `)`, `att_syntax`, or `raw`, found `FOO`
+//~^ ERROR expected one of
 global_asm!("{}", options(), const FOO);
 global_asm!("", clobber_abi(FOO));
 //~^ ERROR expected string literal
`@@` -129,8 +111,6 `@@`
 //~^ ERROR `clobber_abi` cannot be used with `global_asm!`
 global_asm!("{}", options(), clobber_abi("C"), const FOO);
 //~^ ERROR `clobber_abi` cannot be used with `global_asm!`
-global_asm!("", clobber_abi("C"), clobber_abi("C"));
-//~^ ERROR `clobber_abi` cannot be used with `global_asm!`
 global_asm!("{a}", a = const FOO, a = const BAR);
 //~^ ERROR duplicate argument named `a`
 //~^^ ERROR argument never used
`@@` -142,16 +122,3 `@@`
 //~^ ERROR asm template must be a string literal
 global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR);
 //~^ ERROR asm template must be a string literal
-
-global_asm!("{}", in(reg));
-//~^ ERROR the `in` operand cannot be used with `global_asm!`
-global_asm!("{}", out(reg));
-//~^ ERROR the `out` operand cannot be used with `global_asm!`
-global_asm!("{}", lateout(reg));
-//~^ ERROR the `lateout` operand cannot be used with `global_asm!`
-global_asm!("{}", inout(reg));
-//~^ ERROR the `inout` operand cannot be used with `global_asm!`
-global_asm!("{}", inlateout(reg));
-//~^ ERROR the `inlateout` operand cannot be used with `global_asm!`
-global_asm!("{}", label(reg));
-//~^ ERROR the `label` operand cannot be used with `global_asm!`
```
rust-timer added a commit to rust-lang-ci/rust that referenced this issue May 19, 2025
Rollup merge of rust-lang#141242 - folkertdev:aarch64-asm-parse-errors, r=Amanieu

in `tests/ui/asm/aarch64/parse-error.rs`, only test cases specific to that target

this is more in line with the x86 parse error tests at https://github.com/rust-lang/rust/blob/master/tests/ui/asm/x86_64/x86_64_parse_error.rs. We could at this point use minicore so that these tests run no matter the host target?

`tests/ui/asm/aarch64/parse-error.rs` was mostly a copy of https://github.com/rust-lang/rust/blob/master/tests/ui/asm/parse-error.rs, though a bit out of date. The only aarch64-specific tests are those that talk about register names. Here is a diff between those two files:

```diff
--- <unnamed>
+++ <unnamed>
`@@` -1,4 +1,4 `@@`
-//@ needs-asm-support
+//@ only-aarch64

 use std::arch::{asm, global_asm};

`@@` -36,36 +36,12 `@@`
         //~^ ERROR expected one of
         asm!("{}", options(), const foo);
         //~^ ERROR attempt to use a non-constant value in a constant
-
-        // test that asm!'s clobber_abi doesn't accept non-string literals
-        // see also rust-lang#112635
-        asm!("", clobber_abi());
-        //~^ ERROR at least one abi must be provided
         asm!("", clobber_abi(foo));
         //~^ ERROR expected string literal
         asm!("", clobber_abi("C" foo));
         //~^ ERROR expected one of `)` or `,`, found `foo`
         asm!("", clobber_abi("C", foo));
         //~^ ERROR expected string literal
-        asm!("", clobber_abi(1));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi(()));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi(uwu));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi({}));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi(loop {}));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi(if));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi(do));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi(<));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi(.));
-        //~^ ERROR expected string literal
-
         asm!("{}", clobber_abi("C"), const foo);
         //~^ ERROR attempt to use a non-constant value in a constant
         asm!("", options(), clobber_abi("C"));
`@@` -76,7 +52,15 `@@`
         //~^^ ERROR argument never used
         //~^^^ ERROR attempt to use a non-constant value in a constant
         //~^^^^ ERROR attempt to use a non-constant value in a constant
-
+        asm!("", a = in("x0") foo);
+        //~^ ERROR explicit register arguments cannot have names
+        asm!("{a}", in("x0") foo, a = const bar);
+        //~^ ERROR attempt to use a non-constant value in a constant
+        asm!("{a}", in("x0") foo, a = const bar);
+        //~^ ERROR attempt to use a non-constant value in a constant
+        asm!("{1}", in("x0") foo, const bar);
+        //~^ ERROR positional arguments cannot follow named arguments or explicit register arguments
+        //~^^ ERROR attempt to use a non-constant value in a constant
         asm!("", options(), "");
         //~^ ERROR expected one of
         asm!("{}", in(reg) foo, "{}", out(reg) foo);
`@@` -109,13 +93,11 `@@`
 global_asm!("{}", const(reg) FOO);
 //~^ ERROR expected one of
 global_asm!("", options(FOO));
-//~^ ERROR expected one of `)`, `att_syntax`, or `raw`, found `FOO`
-global_asm!("", options(FOO,));
-//~^ ERROR expected one of `)`, `att_syntax`, or `raw`, found `FOO`
+//~^ ERROR expected one of
 global_asm!("", options(nomem FOO));
-//~^ ERROR expected one of `)` or `,`, found `FOO`
+//~^ ERROR expected one of
 global_asm!("", options(nomem, FOO));
-//~^ ERROR expected one of `)`, `att_syntax`, or `raw`, found `FOO`
+//~^ ERROR expected one of
 global_asm!("{}", options(), const FOO);
 global_asm!("", clobber_abi(FOO));
 //~^ ERROR expected string literal
`@@` -129,8 +111,6 `@@`
 //~^ ERROR `clobber_abi` cannot be used with `global_asm!`
 global_asm!("{}", options(), clobber_abi("C"), const FOO);
 //~^ ERROR `clobber_abi` cannot be used with `global_asm!`
-global_asm!("", clobber_abi("C"), clobber_abi("C"));
-//~^ ERROR `clobber_abi` cannot be used with `global_asm!`
 global_asm!("{a}", a = const FOO, a = const BAR);
 //~^ ERROR duplicate argument named `a`
 //~^^ ERROR argument never used
`@@` -142,16 +122,3 `@@`
 //~^ ERROR asm template must be a string literal
 global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR);
 //~^ ERROR asm template must be a string literal
-
-global_asm!("{}", in(reg));
-//~^ ERROR the `in` operand cannot be used with `global_asm!`
-global_asm!("{}", out(reg));
-//~^ ERROR the `out` operand cannot be used with `global_asm!`
-global_asm!("{}", lateout(reg));
-//~^ ERROR the `lateout` operand cannot be used with `global_asm!`
-global_asm!("{}", inout(reg));
-//~^ ERROR the `inout` operand cannot be used with `global_asm!`
-global_asm!("{}", inlateout(reg));
-//~^ ERROR the `inlateout` operand cannot be used with `global_asm!`
-global_asm!("{}", label(reg));
-//~^ ERROR the `label` operand cannot be used with `global_asm!`
```
RalfJung pushed a commit to RalfJung/miri that referenced this issue May 20, 2025
in `tests/ui/asm/aarch64/parse-error.rs`, only test cases specific to that target

this is more in line with the x86 parse error tests at https://github.com/rust-lang/rust/blob/master/tests/ui/asm/x86_64/x86_64_parse_error.rs. We could at this point use minicore so that these tests run no matter the host target?

`tests/ui/asm/aarch64/parse-error.rs` was mostly a copy of https://github.com/rust-lang/rust/blob/master/tests/ui/asm/parse-error.rs, though a bit out of date. The only aarch64-specific tests are those that talk about register names. Here is a diff between those two files:

```diff
--- <unnamed>
+++ <unnamed>
`@@` -1,4 +1,4 `@@`
-//@ needs-asm-support
+//@ only-aarch64

 use std::arch::{asm, global_asm};

`@@` -36,36 +36,12 `@@`
         //~^ ERROR expected one of
         asm!("{}", options(), const foo);
         //~^ ERROR attempt to use a non-constant value in a constant
-
-        // test that asm!'s clobber_abi doesn't accept non-string literals
-        // see also rust-lang/rust#112635
-        asm!("", clobber_abi());
-        //~^ ERROR at least one abi must be provided
         asm!("", clobber_abi(foo));
         //~^ ERROR expected string literal
         asm!("", clobber_abi("C" foo));
         //~^ ERROR expected one of `)` or `,`, found `foo`
         asm!("", clobber_abi("C", foo));
         //~^ ERROR expected string literal
-        asm!("", clobber_abi(1));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi(()));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi(uwu));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi({}));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi(loop {}));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi(if));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi(do));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi(<));
-        //~^ ERROR expected string literal
-        asm!("", clobber_abi(.));
-        //~^ ERROR expected string literal
-
         asm!("{}", clobber_abi("C"), const foo);
         //~^ ERROR attempt to use a non-constant value in a constant
         asm!("", options(), clobber_abi("C"));
`@@` -76,7 +52,15 `@@`
         //~^^ ERROR argument never used
         //~^^^ ERROR attempt to use a non-constant value in a constant
         //~^^^^ ERROR attempt to use a non-constant value in a constant
-
+        asm!("", a = in("x0") foo);
+        //~^ ERROR explicit register arguments cannot have names
+        asm!("{a}", in("x0") foo, a = const bar);
+        //~^ ERROR attempt to use a non-constant value in a constant
+        asm!("{a}", in("x0") foo, a = const bar);
+        //~^ ERROR attempt to use a non-constant value in a constant
+        asm!("{1}", in("x0") foo, const bar);
+        //~^ ERROR positional arguments cannot follow named arguments or explicit register arguments
+        //~^^ ERROR attempt to use a non-constant value in a constant
         asm!("", options(), "");
         //~^ ERROR expected one of
         asm!("{}", in(reg) foo, "{}", out(reg) foo);
`@@` -109,13 +93,11 `@@`
 global_asm!("{}", const(reg) FOO);
 //~^ ERROR expected one of
 global_asm!("", options(FOO));
-//~^ ERROR expected one of `)`, `att_syntax`, or `raw`, found `FOO`
-global_asm!("", options(FOO,));
-//~^ ERROR expected one of `)`, `att_syntax`, or `raw`, found `FOO`
+//~^ ERROR expected one of
 global_asm!("", options(nomem FOO));
-//~^ ERROR expected one of `)` or `,`, found `FOO`
+//~^ ERROR expected one of
 global_asm!("", options(nomem, FOO));
-//~^ ERROR expected one of `)`, `att_syntax`, or `raw`, found `FOO`
+//~^ ERROR expected one of
 global_asm!("{}", options(), const FOO);
 global_asm!("", clobber_abi(FOO));
 //~^ ERROR expected string literal
`@@` -129,8 +111,6 `@@`
 //~^ ERROR `clobber_abi` cannot be used with `global_asm!`
 global_asm!("{}", options(), clobber_abi("C"), const FOO);
 //~^ ERROR `clobber_abi` cannot be used with `global_asm!`
-global_asm!("", clobber_abi("C"), clobber_abi("C"));
-//~^ ERROR `clobber_abi` cannot be used with `global_asm!`
 global_asm!("{a}", a = const FOO, a = const BAR);
 //~^ ERROR duplicate argument named `a`
 //~^^ ERROR argument never used
`@@` -142,16 +122,3 `@@`
 //~^ ERROR asm template must be a string literal
 global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR);
 //~^ ERROR asm template must be a string literal
-
-global_asm!("{}", in(reg));
-//~^ ERROR the `in` operand cannot be used with `global_asm!`
-global_asm!("{}", out(reg));
-//~^ ERROR the `out` operand cannot be used with `global_asm!`
-global_asm!("{}", lateout(reg));
-//~^ ERROR the `lateout` operand cannot be used with `global_asm!`
-global_asm!("{}", inout(reg));
-//~^ ERROR the `inout` operand cannot be used with `global_asm!`
-global_asm!("{}", inlateout(reg));
-//~^ ERROR the `inlateout` operand cannot be used with `global_asm!`
-global_asm!("{}", label(reg));
-//~^ ERROR the `label` operand cannot be used with `global_asm!`
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants