From 1eeed17c9ebc5a5bcae5613cdef77a0fa17828aa Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Mon, 25 Nov 2019 12:34:16 -0800 Subject: Tweak duplicate fmt arg error --- src/libsyntax_ext/format.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/libsyntax_ext') diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 25daca9237f..0a19d64200c 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -172,7 +172,8 @@ fn parse_args<'a>( let e = p.parse_expr()?; if let Some(prev) = names.get(&name) { ecx.struct_span_err(e.span, &format!("duplicate argument named `{}`", name)) - .span_note(args[*prev].span, "previously here") + .span_label(args[*prev].span, "previously here") + .span_label(e.span, "duplicate argument") .emit(); continue; } -- cgit 1.4.1-3-g733a5 From 5ea922aec4a66458728fbe74a6e8096ab76f9aec Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Mon, 25 Nov 2019 12:37:07 -0800 Subject: Various cleanups --- src/librustc_mir/borrow_check/conflict_errors.rs | 18 ++++++------------ src/librustc_parse/parser/item.rs | 17 +++++++++++------ src/librustc_resolve/resolve_imports.rs | 6 ++++-- src/libsyntax_ext/proc_macro_harness.rs | 2 +- 4 files changed, 22 insertions(+), 21 deletions(-) (limited to 'src/libsyntax_ext') diff --git a/src/librustc_mir/borrow_check/conflict_errors.rs b/src/librustc_mir/borrow_check/conflict_errors.rs index ebc25138a06..b78d3475a41 100644 --- a/src/librustc_mir/borrow_check/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/conflict_errors.rs @@ -1256,23 +1256,17 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { Applicability::MachineApplicable, ); - match category { - ConstraintCategory::Return => { - err.span_note(constraint_span, "closure is returned here"); - } - ConstraintCategory::OpaqueType => { - err.span_note(constraint_span, "generator is returned here"); - } + let msg = match category { + ConstraintCategory::Return => "closure is returned here".to_string(), + ConstraintCategory::OpaqueType => "generator is returned here".to_string(), ConstraintCategory::CallArgument => { fr_name.highlight_region_name(&mut err); - err.span_note( - constraint_span, - &format!("function requires argument type to outlive `{}`", fr_name), - ); + format!("function requires argument type to outlive `{}`", fr_name) } _ => bug!("report_escaping_closure_capture called with unexpected constraint \ category: `{:?}`", category), - } + }; + err.span_note(constraint_span, &msg); err } diff --git a/src/librustc_parse/parser/item.rs b/src/librustc_parse/parser/item.rs index 20b96d5cd62..199125125c6 100644 --- a/src/librustc_parse/parser/item.rs +++ b/src/librustc_parse/parser/item.rs @@ -490,9 +490,12 @@ impl<'a> Parser<'a> { } /// Parses a macro invocation inside a `trait`, `impl` or `extern` block. - fn parse_assoc_macro_invoc(&mut self, item_kind: &str, vis: Option<&Visibility>, - at_end: &mut bool) -> PResult<'a, Option> - { + fn parse_assoc_macro_invoc( + &mut self, + item_kind: &str, + vis: Option<&Visibility>, + at_end: &mut bool, + ) -> PResult<'a, Option> { if self.token.is_path_start() && !(self.is_async_fn() && self.token.span.rust_2015()) { let prev_span = self.prev_span; @@ -531,9 +534,11 @@ impl<'a> Parser<'a> { } } - fn missing_assoc_item_kind_err(&self, item_type: &str, prev_span: Span) - -> DiagnosticBuilder<'a> - { + fn missing_assoc_item_kind_err( + &self, + item_type: &str, + prev_span: Span, + ) -> DiagnosticBuilder<'a> { let expected_kinds = if item_type == "extern" { "missing `fn`, `type`, or `static`" } else { diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 5c8e7909631..3ad53737f49 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -1160,8 +1160,10 @@ impl<'a, 'b> ImportResolver<'a, 'b> { .emit(); } else { let msg = format!("`{}` is private, and cannot be re-exported", ident); - let note_msg = - format!("consider marking `{}` as `pub` in the imported module", ident); + let note_msg = format!( + "consider marking `{}` as `pub` in the imported module", + ident, + ); struct_span_err!(self.r.session, directive.span, E0364, "{}", &msg) .span_note(directive.span, ¬e_msg) .emit(); diff --git a/src/libsyntax_ext/proc_macro_harness.rs b/src/libsyntax_ext/proc_macro_harness.rs index fbded7dc130..604400c3cc2 100644 --- a/src/libsyntax_ext/proc_macro_harness.rs +++ b/src/libsyntax_ext/proc_macro_harness.rs @@ -270,7 +270,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> { }; self.handler.struct_span_err(attr.span, &msg) - .span_note(prev_attr.span, "previous attribute here") + .span_label(prev_attr.span, "previous attribute here") .emit(); return; -- cgit 1.4.1-3-g733a5