diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index e40fc04d76645..4880a79ea9cf8 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -882,11 +882,11 @@ impl<'tcx> Printer<'tcx> for V0SymbolMangler<'tcx> { DefPathData::OpaqueTy => 'i', DefPathData::SyntheticCoroutineBody => 's', DefPathData::NestedStatic => 'n', + DefPathData::GlobalAsm => 'a', // These should never show up as `print_path_with_simple` arguments. DefPathData::CrateRoot | DefPathData::Use - | DefPathData::GlobalAsm | DefPathData::Impl | DefPathData::MacroNs(_) | DefPathData::LifetimeNs(_) diff --git a/tests/ui/symbol-names/const-in-global-asm.rs b/tests/ui/symbol-names/const-in-global-asm.rs new file mode 100644 index 0000000000000..61f05c8d90873 --- /dev/null +++ b/tests/ui/symbol-names/const-in-global-asm.rs @@ -0,0 +1,19 @@ +//@ compile-flags: -Clink-dead-code +//@ build-pass + +#![allow(unused)] + +// Test that a symbol in a `global_asm` namespace doesn't cause an ICE during v0 symbol mangling +// due to a lack of missing namespace character for `global_asm`. +// +// FIXME: Can't use `#[rustc_symbol_name]` on the `foo` call to check its symbol, so just checking +// the test compiles. + +fn foo() {} + +core::arch::global_asm!("/* {} */", sym foo::<{ + || {}; + 0 +}>); + +fn main() {}