Mention Register Size in #[warn(asm_sub_register)]

Fixes #121593
This commit is contained in:
Veera
2024-03-03 09:34:26 -05:00
parent d561a84d48
commit 9aac0c9ae3
19 changed files with 100 additions and 92 deletions

View File

@@ -6,6 +6,18 @@ use rustc_span::Symbol;
use std::fmt;
use std::str::FromStr;
pub struct ModifierInfo {
pub modifier: char,
pub result: &'static str,
pub size: u64,
}
impl From<(char, &'static str, u64)> for ModifierInfo {
fn from(value: (char, &'static str, u64)) -> Self {
Self { modifier: value.0, result: value.1, size: value.2 }
}
}
macro_rules! def_reg_class {
($arch:ident $arch_regclass:ident {
$(
@@ -512,11 +524,7 @@ impl InlineAsmRegClass {
/// Such suggestions are useful if a type smaller than the full register
/// size is used and a modifier can be used to point to the subregister of
/// the correct size.
pub fn suggest_modifier(
self,
arch: InlineAsmArch,
ty: InlineAsmType,
) -> Option<(char, &'static str)> {
pub fn suggest_modifier(self, arch: InlineAsmArch, ty: InlineAsmType) -> Option<ModifierInfo> {
match self {
Self::X86(r) => r.suggest_modifier(arch, ty),
Self::Arm(r) => r.suggest_modifier(arch, ty),
@@ -545,7 +553,7 @@ impl InlineAsmRegClass {
/// This is only needed when the register class can suggest a modifier, so
/// that the user can be shown how to get the default behavior without a
/// warning.
pub fn default_modifier(self, arch: InlineAsmArch) -> Option<(char, &'static str)> {
pub fn default_modifier(self, arch: InlineAsmArch) -> Option<ModifierInfo> {
match self {
Self::X86(r) => r.default_modifier(arch),
Self::Arm(r) => r.default_modifier(arch),