1
Fork 0

Changes made in response to feedback

This commit is contained in:
Jean CASPAR 2022-08-19 14:55:06 +02:00
parent e701c72a63
commit 9472df10d0
4 changed files with 25 additions and 19 deletions

View file

@ -124,22 +124,28 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
.iter() .iter()
.map(|(op, op_sp)| { .map(|(op, op_sp)| {
let lower_reg = |reg| match reg { let lower_reg = |reg| match reg {
InlineAsmRegOrRegClass::Reg(s) => { InlineAsmRegOrRegClass::Reg(reg) => {
asm::InlineAsmRegOrRegClass::Reg(if let Some(asm_arch) = asm_arch { asm::InlineAsmRegOrRegClass::Reg(if let Some(asm_arch) = asm_arch {
asm::InlineAsmReg::parse(asm_arch, s).unwrap_or_else(|e| { asm::InlineAsmReg::parse(asm_arch, reg).unwrap_or_else(|error| {
sess.emit_err(InvalidRegister { op_span: *op_sp, s, e }); sess.emit_err(InvalidRegister { op_span: *op_sp, reg, error });
asm::InlineAsmReg::Err asm::InlineAsmReg::Err
}) })
} else { } else {
asm::InlineAsmReg::Err asm::InlineAsmReg::Err
}) })
} }
InlineAsmRegOrRegClass::RegClass(s) => { InlineAsmRegOrRegClass::RegClass(reg_class) => {
asm::InlineAsmRegOrRegClass::RegClass(if let Some(asm_arch) = asm_arch { asm::InlineAsmRegOrRegClass::RegClass(if let Some(asm_arch) = asm_arch {
asm::InlineAsmRegClass::parse(asm_arch, s).unwrap_or_else(|e| { asm::InlineAsmRegClass::parse(asm_arch, reg_class).unwrap_or_else(
sess.emit_err(InvalidRegisterClass { op_span: *op_sp, s, e }); |error| {
sess.emit_err(InvalidRegisterClass {
op_span: *op_sp,
reg_class,
error,
});
asm::InlineAsmRegClass::Err asm::InlineAsmRegClass::Err
}) },
)
} else { } else {
asm::InlineAsmRegClass::Err asm::InlineAsmRegClass::Err
}) })

View file

@ -1,4 +1,4 @@
use rustc_errors::{fluent, AddSubdiagnostic, Applicability, Diagnostic}; use rustc_errors::{fluent, AddSubdiagnostic, Applicability, Diagnostic, DiagnosticArgFromDisplay};
use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic}; use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic};
use rustc_span::{symbol::Ident, Span, Symbol}; use rustc_span::{symbol::Ident, Span, Symbol};
@ -73,10 +73,10 @@ impl AddSubdiagnostic for AssocTyParenthesesSub {
#[derive(SessionDiagnostic)] #[derive(SessionDiagnostic)]
#[diag(ast_lowering::misplaced_impl_trait, code = "E0562")] #[diag(ast_lowering::misplaced_impl_trait, code = "E0562")]
pub struct MisplacedImplTrait { pub struct MisplacedImplTrait<'a> {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
pub position: String, pub position: DiagnosticArgFromDisplay<'a>,
} }
#[derive(SessionDiagnostic, Clone, Copy)] #[derive(SessionDiagnostic, Clone, Copy)]
@ -196,8 +196,8 @@ pub struct InvalidAbiClobberAbi {
pub struct InvalidRegister<'a> { pub struct InvalidRegister<'a> {
#[primary_span] #[primary_span]
pub op_span: Span, pub op_span: Span,
pub s: Symbol, pub reg: Symbol,
pub e: &'a str, pub error: &'a str,
} }
#[derive(SessionDiagnostic, Clone, Copy)] #[derive(SessionDiagnostic, Clone, Copy)]
@ -205,8 +205,8 @@ pub struct InvalidRegister<'a> {
pub struct InvalidRegisterClass<'a> { pub struct InvalidRegisterClass<'a> {
#[primary_span] #[primary_span]
pub op_span: Span, pub op_span: Span,
pub s: Symbol, pub reg_class: Symbol,
pub e: &'a str, pub error: &'a str,
} }
#[derive(SessionDiagnostic)] #[derive(SessionDiagnostic)]

View file

@ -51,7 +51,7 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sorted_map::SortedMap; use rustc_data_structures::sorted_map::SortedMap;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_errors::{Handler, StashKey}; use rustc_errors::{DiagnosticArgFromDisplay, Handler, StashKey};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res}; use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID}; use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
@ -1334,7 +1334,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
ImplTraitContext::Disallowed(position) => { ImplTraitContext::Disallowed(position) => {
self.tcx.sess.emit_err(MisplacedImplTrait { self.tcx.sess.emit_err(MisplacedImplTrait {
span: t.span, span: t.span,
position: position.to_string(), position: DiagnosticArgFromDisplay(&position),
}); });
hir::TyKind::Err hir::TyKind::Err
} }

View file

@ -69,10 +69,10 @@ ast_lowering_invalid_abi_clobber_abi =
.note = the following ABIs are supported on this target: {$supported_abis} .note = the following ABIs are supported on this target: {$supported_abis}
ast_lowering_invalid_register = ast_lowering_invalid_register =
invalid register `{$s}`: {$e} invalid register `{$reg}`: {$error}
ast_lowering_invalid_register_class = ast_lowering_invalid_register_class =
invalid register class `{$s}`: {$e} invalid register class `{$reg_class}`: {$error}
ast_lowering_invalid_asm_template_modifier_reg_class = ast_lowering_invalid_asm_template_modifier_reg_class =
invalid asm template modifier for this register class invalid asm template modifier for this register class