Replace UncoeribleReceiver error message with UndispatchableReceiver

This commit is contained in:
Michael Hewson 2018-10-08 20:37:58 -04:00
parent 3c56d8d0c2
commit 74ef46cfa2
2 changed files with 7 additions and 7 deletions

View file

@ -64,8 +64,8 @@ impl ObjectSafetyViolation {
format!("method `{}` references the `Self` type in where clauses", name).into(),
ObjectSafetyViolation::Method(name, MethodViolationCode::Generic) =>
format!("method `{}` has generic type parameters", name).into(),
ObjectSafetyViolation::Method(name, MethodViolationCode::UncoercibleReceiver) =>
format!("method `{}` has an uncoercible receiver type", name).into(),
ObjectSafetyViolation::Method(name, MethodViolationCode::UndispatchableReceiver) =>
format!("method `{}`'s receiver cannot be dispatched on", name).into(),
ObjectSafetyViolation::AssociatedConst(name) =>
format!("the trait cannot contain associated consts like `{}`", name).into(),
}
@ -87,8 +87,8 @@ pub enum MethodViolationCode {
/// e.g., `fn foo<A>()`
Generic,
/// the self argument can't be coerced from Self=dyn Trait to Self=T where T: Trait
UncoercibleReceiver,
/// the method's receiver (`self` argument) can't be dispatched on
UndispatchableReceiver,
}
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
@ -325,7 +325,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
// `Receiver: Unsize<Receiver[Self => dyn Trait]>`
if receiver_ty != self.mk_self_type() {
if !self.receiver_is_dispatchable(method, receiver_ty) {
return Some(MethodViolationCode::UncoercibleReceiver);
return Some(MethodViolationCode::UndispatchableReceiver);
}
}

View file

@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
LL | let x = Rc::new(5usize) as Rc<Foo>;
| ^^^^^^^ the trait `Foo` cannot be made into an object
|
= note: method `foo` has an uncoercible receiver type
= note: method `foo`'s receiver cannot be dispatched on
error[E0038]: the trait `Foo` cannot be made into an object
--> $DIR/arbitrary-self-types-not-object-safe.rs:40:13
@ -12,7 +12,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
LL | let x = Rc::new(5usize) as Rc<Foo>;
| ^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object
|
= note: method `foo` has an uncoercible receiver type
= note: method `foo`'s receiver cannot be dispatched on
= note: required because of the requirements on the impl of `std::ops::CoerceUnsized<std::rc::Rc<dyn Foo>>` for `std::rc::Rc<usize>`
error: aborting due to 2 previous errors