Mention the full path of the implementing trait

This commit is contained in:
Esteban Küber 2020-02-18 18:20:23 -08:00
parent 89e96e9bc5
commit 0387f0d19b
14 changed files with 32 additions and 27 deletions

View File

@ -574,14 +574,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.tcx
.associated_item(pred.skip_binder().projection_ty.item_def_id);
let ty = pred.skip_binder().ty;
let msg = format!("`{}::{} = {}`", trait_ref, assoc.ident, ty);
let obligation =
format!("`{}::{} = {}`", trait_ref, assoc.ident, ty);
let quiet = format!(
"`<_ as {}>::{} = {}`",
trait_ref.print_only_trait_path(),
assoc.ident,
ty
);
bound_span_label(trait_ref.self_ty(), &msg, &quiet);
bound_span_label(trait_ref.self_ty(), &obligation, &quiet);
Some(obligation)
}
ty::Predicate::Trait(poly_trait_ref, _) => {
@ -994,7 +995,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let Some(span) = self.tcx.hir().span_if_local(trait_info.def_id) {
err.span_label(
self.tcx.sess.source_map().def_span(span),
&format!("this trait defines an item `{}`", item_name),
&format!(
"`{}` defines an item `{}`",
self.tcx.def_path_str(trait_info.def_id),
item_name
),
);
use_note = false
}

View File

@ -2,7 +2,7 @@ error[E0599]: no associated item named `ID` found for type `i32` in the current
--> $DIR/associated-const-no-item.rs:5:23
|
LL | trait Foo {
| --------- this trait defines an item `ID`
| --------- `Foo` defines an item `ID`
...
LL | const X: i32 = <i32>::ID;
| ^^ associated item not found in `i32`

View File

@ -5,7 +5,7 @@ LL | a.test_mut();
| ^^^^^^^^ help: there is a method with a similar name: `get_mut`
...
LL | trait MyIter {
| ------------ this trait defines an item `test_mut`
| ------------ `MyIter` defines an item `test_mut`
|
= help: items from traits can only be used if the trait is implemented and in scope
@ -16,7 +16,7 @@ LL | a.test();
| ^^^^ method not found in `std::vec::Vec<{integer}>`
...
LL | trait MyIter {
| ------------ this trait defines an item `test`
| ------------ `MyIter` defines an item `test`
|
= help: items from traits can only be used if the trait is implemented and in scope
@ -27,7 +27,7 @@ LL | ([1]).test();
| ^^^^ method not found in `[{integer}; 1]`
...
LL | trait MyIter {
| ------------ this trait defines an item `test`
| ------------ `MyIter` defines an item `test`
|
= help: items from traits can only be used if the trait is implemented and in scope
@ -38,7 +38,7 @@ LL | (&[1]).test();
| ^^^^ method not found in `&[{integer}; 1]`
...
LL | trait MyIter {
| ------------ this trait defines an item `test`
| ------------ `MyIter` defines an item `test`
|
= help: items from traits can only be used if the trait is implemented and in scope

View File

@ -2,7 +2,7 @@ error[E0599]: no method named `foo` found for struct `Bar` in the current scope
--> $DIR/issue-21659-show-relevant-trait-impls-3.rs:20:8
|
LL | trait Foo<A> {
| ------------ this trait defines an item `foo`
| ------------ `Foo` defines an item `foo`
...
LL | struct Bar;
| ----------- method `foo` not found for this

View File

@ -123,7 +123,7 @@ error[E0599]: no method named `method2` found for type `u64` in the current scop
--> $DIR/no-method-suggested-traits.rs:45:10
|
LL | pub trait Bar {
| ------------- this trait defines an item `method2`
| ------------- `foo::Bar` defines an item `method2`
...
LL | 1u64.method2();
| ^^^^^^^ method not found in `u64`
@ -134,7 +134,7 @@ error[E0599]: no method named `method2` found for struct `std::rc::Rc<&mut std::
--> $DIR/no-method-suggested-traits.rs:47:44
|
LL | pub trait Bar {
| ------------- this trait defines an item `method2`
| ------------- `foo::Bar` defines an item `method2`
...
LL | std::rc::Rc::new(&mut Box::new(&1u64)).method2();
| ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&u64>>`
@ -145,7 +145,7 @@ error[E0599]: no method named `method2` found for struct `no_method_suggested_tr
--> $DIR/no-method-suggested-traits.rs:50:37
|
LL | pub trait Bar {
| ------------- this trait defines an item `method2`
| ------------- `foo::Bar` defines an item `method2`
...
LL | no_method_suggested_traits::Foo.method2();
| ^^^^^^^ method not found in `no_method_suggested_traits::Foo`
@ -156,7 +156,7 @@ error[E0599]: no method named `method2` found for struct `std::rc::Rc<&mut std::
--> $DIR/no-method-suggested-traits.rs:52:71
|
LL | pub trait Bar {
| ------------- this trait defines an item `method2`
| ------------- `foo::Bar` defines an item `method2`
...
LL | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).method2();
| ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Foo>>`
@ -167,7 +167,7 @@ error[E0599]: no method named `method2` found for enum `no_method_suggested_trai
--> $DIR/no-method-suggested-traits.rs:54:40
|
LL | pub trait Bar {
| ------------- this trait defines an item `method2`
| ------------- `foo::Bar` defines an item `method2`
...
LL | no_method_suggested_traits::Bar::X.method2();
| ^^^^^^^ method not found in `no_method_suggested_traits::Bar`
@ -178,7 +178,7 @@ error[E0599]: no method named `method2` found for struct `std::rc::Rc<&mut std::
--> $DIR/no-method-suggested-traits.rs:56:74
|
LL | pub trait Bar {
| ------------- this trait defines an item `method2`
| ------------- `foo::Bar` defines an item `method2`
...
LL | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Bar::X)).method2();
| ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Bar>>`

View File

@ -2,7 +2,7 @@ error[E0599]: no method named `foo` found for reference `&dyn Foo` in the curren
--> $DIR/issue-5153.rs:10:27
|
LL | trait Foo {
| --------- this trait defines an item `foo`
| --------- `Foo` defines an item `foo`
...
LL | (&5isize as &dyn Foo).foo();
| ^^^ method not found in `&dyn Foo`

View File

@ -2,7 +2,7 @@ error[E0599]: no method named `f` found for fn pointer `fn(&u8)` in the current
--> $DIR/issue-57362-1.rs:20:7
|
LL | trait Trait {
| ----------- this trait defines an item `f`
| ----------- `Trait` defines an item `f`
...
LL | a.f();
| ^ method not found in `fn(&u8)`

View File

@ -2,7 +2,7 @@ error[E0599]: no function or associated item named `make_g` found for fn pointer
--> $DIR/issue-57362-2.rs:22:25
|
LL | trait X {
| ------- this trait defines an item `make_g`
| ------- `X` defines an item `make_g`
...
LL | let x = <fn (&())>::make_g();
| ^^^^^^ function or associated item not found in `for<'r> fn(&'r ())`

View File

@ -10,7 +10,7 @@ error[E0599]: no method named `bind` found for array `[&str; 1]` in the current
--> $DIR/issue-2149.rs:13:12
|
LL | trait VecMonad<A> {
| ----------------- this trait defines an item `bind`
| ----------------- `VecMonad` defines an item `bind`
...
LL | ["hi"].bind(|x| [x] );
| ^^^^ method not found in `[&str; 1]`

View File

@ -2,7 +2,7 @@ error[E0599]: no method named `owned` found for reference `&dyn Foo` in the curr
--> $DIR/object-pointer-types.rs:11:7
|
LL | trait Foo {
| --------- this trait defines an item `owned`
| --------- `Foo` defines an item `owned`
...
LL | x.owned();
| ^^^^^ method not found in `&dyn Foo`
@ -13,7 +13,7 @@ error[E0599]: no method named `owned` found for mutable reference `&mut dyn Foo`
--> $DIR/object-pointer-types.rs:17:7
|
LL | trait Foo {
| --------- this trait defines an item `owned`
| --------- `Foo` defines an item `owned`
...
LL | x.owned();
| ^^^^^ method not found in `&mut dyn Foo`

View File

@ -4,7 +4,7 @@ error[E0599]: no method named `foo` found for struct `A` in the current scope
LL | trait B { fn foo(self: Box<Self>); }
| ------- --- the method is available for `std::boxed::Box<A>` here
| |
| this trait defines an item `foo`
| `B` defines an item `foo`
LL | struct A;
| --------- method `foo` not found for this
...

View File

@ -2,7 +2,7 @@ error[E0599]: no method named `foo_one` found for struct `MyStruct` in the curre
--> $DIR/specialization-trait-not-implemented.rs:22:29
|
LL | trait Foo {
| --------- this trait defines an item `foo_one`
| --------- `Foo` defines an item `foo_one`
...
LL | struct MyStruct;
| ----------------

View File

@ -5,7 +5,7 @@ LL | struct S;
| --------- method `a` not found for this
...
LL | trait A {
| ------- this trait defines an item `a`
| ------- `method::A` defines an item `a`
...
LL | S.a();
| ^ method not found in `S`
@ -47,7 +47,7 @@ LL | struct S;
| --------- function or associated item `a` not found for this
...
LL | trait A {
| ------- this trait defines an item `a`
| ------- `method::A` defines an item `a`
...
LL | S::a(&S);
| ^ function or associated item not found in `S`
@ -82,7 +82,7 @@ LL | struct S;
| --------- associated item `A` not found for this
...
LL | trait A {
| ------- this trait defines an item `A`
| ------- `assoc_const::A` defines an item `A`
...
LL | S::A;
| ^ associated item not found in `S`

View File

@ -12,7 +12,7 @@ error[E0599]: no method named `test` found for type `i32` in the current scope
--> $DIR/trivial-bounds-leak.rs:24:10
|
LL | pub trait Foo {
| ------------- this trait defines an item `test`
| ------------- `Foo` defines an item `test`
...
LL | 3i32.test();
| ^^^^ method not found in `i32`