about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2019-09-03 08:05:54 -0700
committerEsteban Küber <esteban@kuber.com.ar>2019-09-03 08:05:54 -0700
commit4a79633ad2ff5ce1641405daefc41a13d786dacf (patch)
tree6297213c02a7d66d338089d3178434e36aa27733
parent28b518474ed2a5dee812e4f356f71f4c60628421 (diff)
downloadrust-4a79633ad2ff5ce1641405daefc41a13d786dacf.tar.gz
rust-4a79633ad2ff5ce1641405daefc41a13d786dacf.zip
review comments
-rw-r--r--src/librustc/traits/object_safety.rs4
-rw-r--r--src/test/ui/self/arbitrary-self-types-not-object-safe.stderr4
2 files changed, 5 insertions, 3 deletions
diff --git a/src/librustc/traits/object_safety.rs b/src/librustc/traits/object_safety.rs
index 5392e9100c6..f7f459cd27f 100644
--- a/src/librustc/traits/object_safety.rs
+++ b/src/librustc/traits/object_safety.rs
@@ -60,13 +60,15 @@ impl ObjectSafetyViolation {
             ObjectSafetyViolation::Method(name, MethodViolationCode::Generic, _) =>
                 format!("method `{}` has generic type parameters", name).into(),
             ObjectSafetyViolation::Method(name, MethodViolationCode::UndispatchableReceiver, _) =>
-                format!("method `{}`'s receiver cannot be dispatched on", name).into(),
+                format!("method `{}`'s `self` parameter cannot be dispatched on", name).into(),
             ObjectSafetyViolation::AssocConst(name, _) =>
                 format!("the trait cannot contain associated consts like `{}`", name).into(),
         }
     }
 
     pub fn span(&self) -> Option<Span> {
+        // When `span` comes from a separate crate, it'll be `DUMMY_SP`. Treat it as `None` so
+        // diagnostics use a `note` instead of a `span_label`.
         match *self {
             ObjectSafetyViolation::AssocConst(_, span) |
             ObjectSafetyViolation::Method(_, _, span) if span != DUMMY_SP => Some(span),
diff --git a/src/test/ui/self/arbitrary-self-types-not-object-safe.stderr b/src/test/ui/self/arbitrary-self-types-not-object-safe.stderr
index 9fb1500afce..e6eba377a95 100644
--- a/src/test/ui/self/arbitrary-self-types-not-object-safe.stderr
+++ b/src/test/ui/self/arbitrary-self-types-not-object-safe.stderr
@@ -2,7 +2,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
   --> $DIR/arbitrary-self-types-not-object-safe.rs:31:32
    |
 LL |     fn foo(self: &Rc<Self>) -> usize;
-   |        --- method `foo`'s receiver cannot be dispatched on
+   |        --- method `foo`'s `self` parameter cannot be dispatched on
 ...
 LL |     let x = Rc::new(5usize) as Rc<dyn Foo>;
    |                                ^^^^^^^^^^^ the trait `Foo` cannot be made into an object
@@ -11,7 +11,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
   --> $DIR/arbitrary-self-types-not-object-safe.rs:31:13
    |
 LL |     fn foo(self: &Rc<Self>) -> usize;
-   |        --- method `foo`'s receiver cannot be dispatched on
+   |        --- method `foo`'s `self` parameter cannot be dispatched on
 ...
 LL |     let x = Rc::new(5usize) as Rc<dyn Foo>;
    |             ^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object