]> git.lizzy.rs Git - rust.git/commitdiff
Changes made in response to feedback
authorJean CASPAR <55629512+JeanCASPAR@users.noreply.github.com>
Fri, 19 Aug 2022 12:55:06 +0000 (14:55 +0200)
committerJean CASPAR <55629512+JeanCASPAR@users.noreply.github.com>
Mon, 22 Aug 2022 17:24:14 +0000 (19:24 +0200)
compiler/rustc_ast_lowering/src/asm.rs
compiler/rustc_ast_lowering/src/errors.rs
compiler/rustc_ast_lowering/src/lib.rs
compiler/rustc_error_messages/locales/en-US/ast_lowering.ftl

index d246510e0c1ed33449e82fe59fee700d4a019df5..0dba9da63da2a03d0d18c3ccfe2697d5b672252e 100644 (file)
@@ -124,22 +124,28 @@ pub(crate) fn lower_inline_asm(
             .iter()
             .map(|(op, op_sp)| {
                 let lower_reg = |reg| match reg {
-                    InlineAsmRegOrRegClass::Reg(s) => {
+                    InlineAsmRegOrRegClass::Reg(reg) => {
                         asm::InlineAsmRegOrRegClass::Reg(if let Some(asm_arch) = asm_arch {
-                            asm::InlineAsmReg::parse(asm_arch, s).unwrap_or_else(|e| {
-                                sess.emit_err(InvalidRegister { op_span: *op_sp, s, e });
+                            asm::InlineAsmReg::parse(asm_arch, reg).unwrap_or_else(|error| {
+                                sess.emit_err(InvalidRegister { op_span: *op_sp, reg, error });
                                 asm::InlineAsmReg::Err
                             })
                         } else {
                             asm::InlineAsmReg::Err
                         })
                     }
-                    InlineAsmRegOrRegClass::RegClass(s) => {
+                    InlineAsmRegOrRegClass::RegClass(reg_class) => {
                         asm::InlineAsmRegOrRegClass::RegClass(if let Some(asm_arch) = asm_arch {
-                            asm::InlineAsmRegClass::parse(asm_arch, s).unwrap_or_else(|e| {
-                                sess.emit_err(InvalidRegisterClass { op_span: *op_sp, s, e });
-                                asm::InlineAsmRegClass::Err
-                            })
+                            asm::InlineAsmRegClass::parse(asm_arch, reg_class).unwrap_or_else(
+                                |error| {
+                                    sess.emit_err(InvalidRegisterClass {
+                                        op_span: *op_sp,
+                                        reg_class,
+                                        error,
+                                    });
+                                    asm::InlineAsmRegClass::Err
+                                },
+                            )
                         } else {
                             asm::InlineAsmRegClass::Err
                         })
index 2da42c96ec0cf02bbef9adf786d463f299b25544..edc7ac9fbe383c4c518e1bef32e5beceecc518ae 100644 (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_span::{symbol::Ident, Span, Symbol};
 
@@ -73,10 +73,10 @@ fn add_to_diagnostic(self, diag: &mut Diagnostic) {
 
 #[derive(SessionDiagnostic)]
 #[diag(ast_lowering::misplaced_impl_trait, code = "E0562")]
-pub struct MisplacedImplTrait {
+pub struct MisplacedImplTrait<'a> {
     #[primary_span]
     pub span: Span,
-    pub position: String,
+    pub position: DiagnosticArgFromDisplay<'a>,
 }
 
 #[derive(SessionDiagnostic, Clone, Copy)]
@@ -196,8 +196,8 @@ pub struct InvalidAbiClobberAbi {
 pub struct InvalidRegister<'a> {
     #[primary_span]
     pub op_span: Span,
-    pub s: Symbol,
-    pub e: &'a str,
+    pub reg: Symbol,
+    pub error: &'a str,
 }
 
 #[derive(SessionDiagnostic, Clone, Copy)]
@@ -205,8 +205,8 @@ pub struct InvalidRegister<'a> {
 pub struct InvalidRegisterClass<'a> {
     #[primary_span]
     pub op_span: Span,
-    pub s: Symbol,
-    pub e: &'a str,
+    pub reg_class: Symbol,
+    pub error: &'a str,
 }
 
 #[derive(SessionDiagnostic)]
index a44c3c0d23b9e077481e128e9c4a15ddb68c70d1..ed28f81f88ead800a80e97a93729f092cab2cdd6 100644 (file)
@@ -51,7 +51,7 @@
 use rustc_data_structures::sorted_map::SortedMap;
 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
 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::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
 use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
@@ -1334,7 +1334,7 @@ fn lower_ty_direct(&mut self, t: &Ty, itctx: ImplTraitContext) -> hir::Ty<'hir>
                     ImplTraitContext::Disallowed(position) => {
                         self.tcx.sess.emit_err(MisplacedImplTrait {
                             span: t.span,
-                            position: position.to_string(),
+                            position: DiagnosticArgFromDisplay(&position),
                         });
                         hir::TyKind::Err
                     }
index 8effd9ca75017d559896c0b7c9be913e5a598788..dcb1e2b08306fe65b23864db9ab851ba9ee1bb65 100644 (file)
@@ -69,10 +69,10 @@ ast_lowering_invalid_abi_clobber_abi =
     .note = the following ABIs are supported on this target: {$supported_abis}
 
 ast_lowering_invalid_register =
-    invalid register `{$s}`: {$e}
+    invalid register `{$reg}`: {$error}
 
 ast_lowering_invalid_register_class =
-    invalid register class `{$s}`: {$e}
+    invalid register class `{$reg_class}`: {$error}
 
 ast_lowering_invalid_asm_template_modifier_reg_class =
     invalid asm template modifier for this register class