1
Fork 0

Rollup merge of #136239 - folkertdev:show-supported-register-classes, r=SparrowLii,jieyouxu

show supported register classes in error message

a simple diagnostic change that shows the supported register classes when an invalid one is found.

This information can be hard to find (especially for unstable targets), and this message now gives at least something to try or search for. I've followed the pattern for invalid clobber ABIs.

`@rustbot` label +A-inline-assembly
This commit is contained in:
Matthias Krüger 2025-02-11 18:04:34 +01:00 committed by GitHub
commit 65d20f39f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 23 additions and 8 deletions

View file

@ -39,12 +39,12 @@ macro_rules! def_reg_class {
}
}
pub fn parse(name: rustc_span::Symbol) -> Result<Self, &'static str> {
pub fn parse(name: rustc_span::Symbol) -> Result<Self, &'static [rustc_span::Symbol]> {
match name {
$(
rustc_span::sym::$class => Ok(Self::$class),
)*
_ => Err("unknown register class"),
_ => Err(&[$(rustc_span::sym::$class),*]),
}
}
}
@ -635,7 +635,7 @@ impl InlineAsmRegClass {
}
}
pub fn parse(arch: InlineAsmArch, name: Symbol) -> Result<Self, &'static str> {
pub fn parse(arch: InlineAsmArch, name: Symbol) -> Result<Self, &'static [rustc_span::Symbol]> {
Ok(match arch {
InlineAsmArch::X86 | InlineAsmArch::X86_64 => {
Self::X86(X86InlineAsmRegClass::parse(name)?)