Skip to content

Commit e34da16

Browse files
committed
Changes made in response to feedback
1 parent 943f03f commit e34da16

File tree

4 files changed

+25
-19
lines changed

4 files changed

+25
-19
lines changed

compiler/rustc_ast_lowering/src/asm.rs

+14-8
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,28 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
124124
.iter()
125125
.map(|(op, op_sp)| {
126126
let lower_reg = |reg| match reg {
127-
InlineAsmRegOrRegClass::Reg(s) => {
127+
InlineAsmRegOrRegClass::Reg(reg) => {
128128
asm::InlineAsmRegOrRegClass::Reg(if let Some(asm_arch) = asm_arch {
129-
asm::InlineAsmReg::parse(asm_arch, s).unwrap_or_else(|e| {
130-
sess.emit_err(InvalidRegister { op_span: *op_sp, s, e });
129+
asm::InlineAsmReg::parse(asm_arch, reg).unwrap_or_else(|error| {
130+
sess.emit_err(InvalidRegister { op_span: *op_sp, reg, error });
131131
asm::InlineAsmReg::Err
132132
})
133133
} else {
134134
asm::InlineAsmReg::Err
135135
})
136136
}
137-
InlineAsmRegOrRegClass::RegClass(s) => {
137+
InlineAsmRegOrRegClass::RegClass(reg_class) => {
138138
asm::InlineAsmRegOrRegClass::RegClass(if let Some(asm_arch) = asm_arch {
139-
asm::InlineAsmRegClass::parse(asm_arch, s).unwrap_or_else(|e| {
140-
sess.emit_err(InvalidRegisterClass { op_span: *op_sp, s, e });
141-
asm::InlineAsmRegClass::Err
142-
})
139+
asm::InlineAsmRegClass::parse(asm_arch, reg_class).unwrap_or_else(
140+
|error| {
141+
sess.emit_err(InvalidRegisterClass {
142+
op_span: *op_sp,
143+
reg_class,
144+
error,
145+
});
146+
asm::InlineAsmRegClass::Err
147+
},
148+
)
143149
} else {
144150
asm::InlineAsmRegClass::Err
145151
})

compiler/rustc_ast_lowering/src/errors.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_errors::{fluent, AddSubdiagnostic, Applicability, Diagnostic};
1+
use rustc_errors::{fluent, AddSubdiagnostic, Applicability, Diagnostic, DiagnosticArgFromDisplay};
22
use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic};
33
use rustc_span::{symbol::Ident, Span, Symbol};
44

@@ -73,10 +73,10 @@ impl AddSubdiagnostic for AssocTyParenthesesSub {
7373

7474
#[derive(SessionDiagnostic)]
7575
#[error(ast_lowering::misplaced_impl_trait, code = "E0562")]
76-
pub struct MisplacedImplTrait {
76+
pub struct MisplacedImplTrait<'a> {
7777
#[primary_span]
7878
pub span: Span,
79-
pub position: String,
79+
pub position: DiagnosticArgFromDisplay<'a>,
8080
}
8181

8282
#[derive(SessionDiagnostic, Clone, Copy)]
@@ -196,17 +196,17 @@ pub struct InvalidAbiClobberAbi {
196196
pub struct InvalidRegister<'a> {
197197
#[primary_span]
198198
pub op_span: Span,
199-
pub s: Symbol,
200-
pub e: &'a str,
199+
pub reg: Symbol,
200+
pub error: &'a str,
201201
}
202202

203203
#[derive(SessionDiagnostic, Clone, Copy)]
204204
#[error(ast_lowering::invalid_register_class)]
205205
pub struct InvalidRegisterClass<'a> {
206206
#[primary_span]
207207
pub op_span: Span,
208-
pub s: Symbol,
209-
pub e: &'a str,
208+
pub reg_class: Symbol,
209+
pub error: &'a str,
210210
}
211211

212212
#[derive(SessionDiagnostic)]

compiler/rustc_ast_lowering/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use rustc_data_structures::fx::FxHashMap;
5151
use rustc_data_structures::sorted_map::SortedMap;
5252
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
5353
use rustc_data_structures::sync::Lrc;
54-
use rustc_errors::{Handler, StashKey};
54+
use rustc_errors::{DiagnosticArgFromDisplay, Handler, StashKey};
5555
use rustc_hir as hir;
5656
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
5757
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
@@ -1334,7 +1334,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13341334
ImplTraitContext::Disallowed(position) => {
13351335
self.tcx.sess.emit_err(MisplacedImplTrait {
13361336
span: t.span,
1337-
position: position.to_string(),
1337+
position: DiagnosticArgFromDisplay(&position),
13381338
});
13391339
hir::TyKind::Err
13401340
}

compiler/rustc_error_messages/locales/en-US/ast_lowering.ftl

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ ast_lowering_invalid_abi_clobber_abi =
6969
.note = the following ABIs are supported on this target: {$supported_abis}
7070
7171
ast_lowering_invalid_register =
72-
invalid register `{$s}`: {$e}
72+
invalid register `{$reg}`: {$error}
7373
7474
ast_lowering_invalid_register_class =
75-
invalid register class `{$s}`: {$e}
75+
invalid register class `{$reg_class}`: {$error}
7676
7777
ast_lowering_invalid_asm_template_modifier_reg_class =
7878
invalid asm template modifier for this register class

0 commit comments

Comments
 (0)