From 0f7f2346a688466624d10bfa8310b8d6aedd0ede Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 15 Oct 2019 20:35:54 -0700 Subject: [PATCH] Remove unnecessary note --- src/librustc/traits/error_reporting.rs | 21 +++++++++---------- src/libsyntax_pos/lib.rs | 5 ----- src/test/ui/suggestions/issue-62843.stderr | 1 - .../ui/traits/traits-negative-impls.stderr | 2 -- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 76bb28f7e948..ffd4560d32d8 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -771,6 +771,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { ) }; + if self.suggest_add_reference_to_arg( + &obligation, + &mut err, + &trait_ref, + points_at_arg, + ) { + self.note_obligation_cause(&mut err, obligation); + err.emit(); + return; + } if let Some(ref s) = label { // If it has a custom `#[rustc_on_unimplemented]` // error message, let's display it as the label! @@ -787,16 +797,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { self.suggest_borrow_on_unsized_slice(&obligation.cause.code, &mut err); self.suggest_fn_call(&obligation, &mut err, &trait_ref, points_at_arg); self.suggest_remove_reference(&obligation, &mut err, &trait_ref); - if self.suggest_add_reference_to_arg( - &obligation, - &mut err, - &trait_ref, - points_at_arg, - ) { - self.note_obligation_cause(&mut err, obligation); - err.emit(); - return; - } self.suggest_semicolon_removal(&obligation, &mut err, span, &trait_ref); // Try to report a help message @@ -1359,7 +1359,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { // somewhere else in the obligation chain. Do not suggest non-sense. return false; } - err.span.clear_span_labels(); err.span_label(span, &format!( "expected an implementor of trait `{}`", obligation.parent_trait_ref.skip_binder(), diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index fc8c72e4f232..b88d6dbc3f37 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -736,11 +736,6 @@ impl MultiSpan { replacements_occurred } - /// This should be *rarely* used. Remove all the labels in this `MultiSpan`. - pub fn clear_span_labels(&mut self) { - self.span_labels.clear(); - } - /// Returns the strings to highlight. We always ensure that there /// is an entry for each of the primary spans -- for each primary /// span `P`, if there is at least one label with span `P`, we return diff --git a/src/test/ui/suggestions/issue-62843.stderr b/src/test/ui/suggestions/issue-62843.stderr index ecaa39dbd2c8..1e0ae9bd0622 100644 --- a/src/test/ui/suggestions/issue-62843.stderr +++ b/src/test/ui/suggestions/issue-62843.stderr @@ -7,7 +7,6 @@ LL | println!("{:?}", line.find(pattern)); | expected an implementor of trait `std::str::pattern::Pattern<'_>` | help: consider borrowing here: `&pattern` | - = help: the trait `std::ops::FnMut<(char,)>` is not implemented for `std::string::String` = note: required because of the requirements on the impl of `std::str::pattern::Pattern<'_>` for `std::string::String` error: aborting due to previous error diff --git a/src/test/ui/traits/traits-negative-impls.stderr b/src/test/ui/traits/traits-negative-impls.stderr index cfb8b1d7b5f3..f68cc6a37049 100644 --- a/src/test/ui/traits/traits-negative-impls.stderr +++ b/src/test/ui/traits/traits-negative-impls.stderr @@ -55,7 +55,6 @@ LL | is_send(Box::new(TestType)); | expected an implementor of trait `std::marker::Send` | help: consider borrowing here: `&Box::new(TestType)` | - = help: the trait `std::marker::Send` is not implemented for `dummy2::TestType` = note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique` = note: required because it appears within the type `std::boxed::Box` @@ -85,7 +84,6 @@ LL | is_sync(Outer2(TestType)); | expected an implementor of trait `std::marker::Sync` | help: consider borrowing here: `&Outer2(TestType)` | - = help: the trait `std::marker::Send` is not implemented for `main::TestType` = note: required because of the requirements on the impl of `std::marker::Sync` for `Outer2` error: aborting due to 7 previous errors