Skip to content

Commit 4a79633

Browse files
committed
review comments
1 parent 28b5184 commit 4a79633

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/librustc/traits/object_safety.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,15 @@ impl ObjectSafetyViolation {
6060
ObjectSafetyViolation::Method(name, MethodViolationCode::Generic, _) =>
6161
format!("method `{}` has generic type parameters", name).into(),
6262
ObjectSafetyViolation::Method(name, MethodViolationCode::UndispatchableReceiver, _) =>
63-
format!("method `{}`'s receiver cannot be dispatched on", name).into(),
63+
format!("method `{}`'s `self` parameter cannot be dispatched on", name).into(),
6464
ObjectSafetyViolation::AssocConst(name, _) =>
6565
format!("the trait cannot contain associated consts like `{}`", name).into(),
6666
}
6767
}
6868

6969
pub fn span(&self) -> Option<Span> {
70+
// When `span` comes from a separate crate, it'll be `DUMMY_SP`. Treat it as `None` so
71+
// diagnostics use a `note` instead of a `span_label`.
7072
match *self {
7173
ObjectSafetyViolation::AssocConst(_, span) |
7274
ObjectSafetyViolation::Method(_, _, span) if span != DUMMY_SP => Some(span),

src/test/ui/self/arbitrary-self-types-not-object-safe.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
22
--> $DIR/arbitrary-self-types-not-object-safe.rs:31:32
33
|
44
LL | fn foo(self: &Rc<Self>) -> usize;
5-
| --- method `foo`'s receiver cannot be dispatched on
5+
| --- method `foo`'s `self` parameter cannot be dispatched on
66
...
77
LL | let x = Rc::new(5usize) as Rc<dyn Foo>;
88
| ^^^^^^^^^^^ the trait `Foo` cannot be made into an object
@@ -11,7 +11,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
1111
--> $DIR/arbitrary-self-types-not-object-safe.rs:31:13
1212
|
1313
LL | fn foo(self: &Rc<Self>) -> usize;
14-
| --- method `foo`'s receiver cannot be dispatched on
14+
| --- method `foo`'s `self` parameter cannot be dispatched on
1515
...
1616
LL | let x = Rc::new(5usize) as Rc<dyn Foo>;
1717
| ^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object

0 commit comments

Comments
 (0)