diff options
| author | Cameron Steffen <cam.steffen94@gmail.com> | 2025-07-30 18:00:53 -0500 |
|---|---|---|
| committer | Cameron Steffen <cam.steffen94@gmail.com> | 2025-08-11 16:58:21 -0500 |
| commit | 3aa0ac0a8af32f2c5da106c5e89bd9712d5a9655 (patch) | |
| tree | 8eb1d8cae95b4d555250443f0eb14972125a95f4 /compiler/rustc_parse/src/parser/item.rs | |
| parent | fa733909edadf390cde8c36c303bce42d37f7a3b (diff) | |
| download | rust-3aa0ac0a8af32f2c5da106c5e89bd9712d5a9655.tar.gz rust-3aa0ac0a8af32f2c5da106c5e89bd9712d5a9655.zip | |
Tweak trait modifier errors
Diffstat (limited to 'compiler/rustc_parse/src/parser/item.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 96d7120e21e..75cb103d5d6 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -667,36 +667,27 @@ impl<'a> Parser<'a> { } None => { let self_ty = ty_first; - let error = |annotation_span, annotation, only_trait| { - errors::TraitImplModifierInInherentImpl { + let error = |modifier, modifier_name, modifier_span| { + self.dcx().create_err(errors::TraitImplModifierInInherentImpl { span: self_ty.span, - annotation_span, - annotation, + modifier, + modifier_name, + modifier_span, self_ty: self_ty.span, - only_trait, - } + }) }; if let Safety::Unsafe(span) = safety { - self.dcx() - .create_err(errors::TraitImplModifierInInherentImpl { - span: self_ty.span, - annotation_span: span, - annotation: "unsafe", - self_ty: self_ty.span, - only_trait: true, - }) - .with_code(E0197) - .emit(); + error("unsafe", "unsafe", span).with_code(E0197).emit(); } if let ImplPolarity::Negative(span) = polarity { - self.dcx().emit_err(error(span, "negative", false)); + error("!", "negative", span).emit(); } if let Defaultness::Default(def_span) = defaultness { - self.dcx().emit_err(error(def_span, "`default`", true)); + error("default", "default", def_span).emit(); } if let Const::Yes(span) = constness { - self.dcx().emit_err(error(span, "`const`", true)); + error("const", "const", span).emit(); } (None, self_ty) } |
