about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/traits/error_reporting.rs5
-rw-r--r--src/libsyntax_pos/lib.rs5
-rw-r--r--src/test/ui/derives/deriving-copyclone.stderr6
-rw-r--r--src/test/ui/suggestions/issue-62843.stderr2
-rw-r--r--src/test/ui/traits/traits-negative-impls.stderr4
5 files changed, 16 insertions, 6 deletions
diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs
index f511862b37b..76bb28f7e94 100644
--- a/src/librustc/traits/error_reporting.rs
+++ b/src/librustc/traits/error_reporting.rs
@@ -1359,6 +1359,11 @@ 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(),
+                    ));
                     err.span_suggestion(
                         span,
                         "consider borrowing here",
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs
index b88d6dbc3f3..fc8c72e4f23 100644
--- a/src/libsyntax_pos/lib.rs
+++ b/src/libsyntax_pos/lib.rs
@@ -736,6 +736,11 @@ 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/derives/deriving-copyclone.stderr b/src/test/ui/derives/deriving-copyclone.stderr
index 561706469c6..e23d48ca630 100644
--- a/src/test/ui/derives/deriving-copyclone.stderr
+++ b/src/test/ui/derives/deriving-copyclone.stderr
@@ -7,7 +7,7 @@ LL | fn is_copy<T: Copy>(_: T) {}
 LL |     is_copy(B { a: 1, b: C });
    |             ^^^^^^^^^^^^^^^^
    |             |
-   |             the trait `std::marker::Copy` is not implemented for `C`
+   |             expected an implementor of trait `std::marker::Copy`
    |             help: consider borrowing here: `&B { a: 1, b: C }`
    |
    = note: required because of the requirements on the impl of `std::marker::Copy` for `B<C>`
@@ -21,7 +21,7 @@ LL | fn is_clone<T: Clone>(_: T) {}
 LL |     is_clone(B { a: 1, b: C });
    |              ^^^^^^^^^^^^^^^^
    |              |
-   |              the trait `std::clone::Clone` is not implemented for `C`
+   |              expected an implementor of trait `std::clone::Clone`
    |              help: consider borrowing here: `&B { a: 1, b: C }`
    |
    = note: required because of the requirements on the impl of `std::clone::Clone` for `B<C>`
@@ -35,7 +35,7 @@ LL | fn is_copy<T: Copy>(_: T) {}
 LL |     is_copy(B { a: 1, b: D });
    |             ^^^^^^^^^^^^^^^^
    |             |
-   |             the trait `std::marker::Copy` is not implemented for `D`
+   |             expected an implementor of trait `std::marker::Copy`
    |             help: consider borrowing here: `&B { a: 1, b: D }`
    |
    = note: required because of the requirements on the impl of `std::marker::Copy` for `B<D>`
diff --git a/src/test/ui/suggestions/issue-62843.stderr b/src/test/ui/suggestions/issue-62843.stderr
index 9535bf1b2ce..ecaa39dbd2c 100644
--- a/src/test/ui/suggestions/issue-62843.stderr
+++ b/src/test/ui/suggestions/issue-62843.stderr
@@ -4,7 +4,7 @@ error[E0277]: the trait bound `std::string::String: std::str::pattern::Pattern<'
 LL |     println!("{:?}", line.find(pattern));
    |                                ^^^^^^^
    |                                |
-   |                                expected an `FnMut<(char,)>` closure, found `std::string::String`
+   |                                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`
diff --git a/src/test/ui/traits/traits-negative-impls.stderr b/src/test/ui/traits/traits-negative-impls.stderr
index 448bb90205d..cfb8b1d7b5f 100644
--- a/src/test/ui/traits/traits-negative-impls.stderr
+++ b/src/test/ui/traits/traits-negative-impls.stderr
@@ -52,7 +52,7 @@ LL | fn is_send<T: Send>(_: T) {}
 LL |     is_send(Box::new(TestType));
    |             ^^^^^^^^^^^^^^^^^^
    |             |
-   |             `dummy2::TestType` cannot be sent between threads safely
+   |             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`
@@ -82,7 +82,7 @@ LL | fn is_sync<T: Sync>(_: T) {}
 LL |     is_sync(Outer2(TestType));
    |             ^^^^^^^^^^^^^^^^
    |             |
-   |             `main::TestType` cannot be sent between threads safely
+   |             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`