Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Sep 3, 2019
1 parent 28b5184 commit 4a79633
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/librustc/traits/object_safety.rs
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/self/arbitrary-self-types-not-object-safe.stderr
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 4a79633

Please sign in to comment.