Skip to content

Commit 9245415

Browse files
committed
Mention the full path of the implementing trait
1 parent 615542a commit 9245415

14 files changed

+32
-27
lines changed

src/librustc_typeck/check/method/suggest.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,14 +574,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
574574
.tcx
575575
.associated_item(pred.skip_binder().projection_ty.item_def_id);
576576
let ty = pred.skip_binder().ty;
577-
let msg = format!("`{}::{} = {}`", trait_ref, assoc.ident, ty);
577+
let obligation =
578+
format!("`{}::{} = {}`", trait_ref, assoc.ident, ty);
578579
let quiet = format!(
579580
"`<_ as {}>::{} = {}`",
580581
trait_ref.print_only_trait_path(),
581582
assoc.ident,
582583
ty
583584
);
584-
bound_span_label(trait_ref.self_ty(), &msg, &quiet);
585+
bound_span_label(trait_ref.self_ty(), &obligation, &quiet);
585586
Some(obligation)
586587
}
587588
ty::Predicate::Trait(poly_trait_ref, _) => {
@@ -994,7 +995,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
994995
if let Some(span) = self.tcx.hir().span_if_local(trait_info.def_id) {
995996
err.span_label(
996997
self.tcx.sess.source_map().def_span(span),
997-
&format!("this trait defines an item `{}`", item_name),
998+
&format!(
999+
"`{}` defines an item `{}`",
1000+
self.tcx.def_path_str(trait_info.def_id),
1001+
item_name
1002+
),
9981003
);
9991004
use_note = false
10001005
}

src/test/ui/associated-const/associated-const-no-item.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0599]: no associated item named `ID` found for type `i32` in the current
22
--> $DIR/associated-const-no-item.rs:5:23
33
|
44
LL | trait Foo {
5-
| --------- this trait defines an item `ID`
5+
| --------- `Foo` defines an item `ID`
66
...
77
LL | const X: i32 = <i32>::ID;
88
| ^^ associated item not found in `i32`

src/test/ui/auto-ref-slice-plus-ref.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | a.test_mut();
55
| ^^^^^^^^ help: there is a method with a similar name: `get_mut`
66
...
77
LL | trait MyIter {
8-
| ------------ this trait defines an item `test_mut`
8+
| ------------ `MyIter` defines an item `test_mut`
99
|
1010
= help: items from traits can only be used if the trait is implemented and in scope
1111

@@ -16,7 +16,7 @@ LL | a.test();
1616
| ^^^^ method not found in `std::vec::Vec<{integer}>`
1717
...
1818
LL | trait MyIter {
19-
| ------------ this trait defines an item `test`
19+
| ------------ `MyIter` defines an item `test`
2020
|
2121
= help: items from traits can only be used if the trait is implemented and in scope
2222

@@ -27,7 +27,7 @@ LL | ([1]).test();
2727
| ^^^^ method not found in `[{integer}; 1]`
2828
...
2929
LL | trait MyIter {
30-
| ------------ this trait defines an item `test`
30+
| ------------ `MyIter` defines an item `test`
3131
|
3232
= help: items from traits can only be used if the trait is implemented and in scope
3333

@@ -38,7 +38,7 @@ LL | (&[1]).test();
3838
| ^^^^ method not found in `&[{integer}; 1]`
3939
...
4040
LL | trait MyIter {
41-
| ------------ this trait defines an item `test`
41+
| ------------ `MyIter` defines an item `test`
4242
|
4343
= help: items from traits can only be used if the trait is implemented and in scope
4444

src/test/ui/impl-trait/issues/issue-21659-show-relevant-trait-impls-3.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0599]: no method named `foo` found for struct `Bar` in the current scope
22
--> $DIR/issue-21659-show-relevant-trait-impls-3.rs:20:8
33
|
44
LL | trait Foo<A> {
5-
| ------------ this trait defines an item `foo`
5+
| ------------ `Foo` defines an item `foo`
66
...
77
LL | struct Bar;
88
| ----------- method `foo` not found for this

src/test/ui/impl-trait/no-method-suggested-traits.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ error[E0599]: no method named `method2` found for type `u64` in the current scop
123123
--> $DIR/no-method-suggested-traits.rs:45:10
124124
|
125125
LL | pub trait Bar {
126-
| ------------- this trait defines an item `method2`
126+
| ------------- `foo::Bar` defines an item `method2`
127127
...
128128
LL | 1u64.method2();
129129
| ^^^^^^^ method not found in `u64`
@@ -134,7 +134,7 @@ error[E0599]: no method named `method2` found for struct `std::rc::Rc<&mut std::
134134
--> $DIR/no-method-suggested-traits.rs:47:44
135135
|
136136
LL | pub trait Bar {
137-
| ------------- this trait defines an item `method2`
137+
| ------------- `foo::Bar` defines an item `method2`
138138
...
139139
LL | std::rc::Rc::new(&mut Box::new(&1u64)).method2();
140140
| ^^^^^^^ 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
145145
--> $DIR/no-method-suggested-traits.rs:50:37
146146
|
147147
LL | pub trait Bar {
148-
| ------------- this trait defines an item `method2`
148+
| ------------- `foo::Bar` defines an item `method2`
149149
...
150150
LL | no_method_suggested_traits::Foo.method2();
151151
| ^^^^^^^ 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::
156156
--> $DIR/no-method-suggested-traits.rs:52:71
157157
|
158158
LL | pub trait Bar {
159-
| ------------- this trait defines an item `method2`
159+
| ------------- `foo::Bar` defines an item `method2`
160160
...
161161
LL | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).method2();
162162
| ^^^^^^^ 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
167167
--> $DIR/no-method-suggested-traits.rs:54:40
168168
|
169169
LL | pub trait Bar {
170-
| ------------- this trait defines an item `method2`
170+
| ------------- `foo::Bar` defines an item `method2`
171171
...
172172
LL | no_method_suggested_traits::Bar::X.method2();
173173
| ^^^^^^^ 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::
178178
--> $DIR/no-method-suggested-traits.rs:56:74
179179
|
180180
LL | pub trait Bar {
181-
| ------------- this trait defines an item `method2`
181+
| ------------- `foo::Bar` defines an item `method2`
182182
...
183183
LL | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Bar::X)).method2();
184184
| ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Bar>>`

src/test/ui/issues/issue-5153.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0599]: no method named `foo` found for reference `&dyn Foo` in the curren
22
--> $DIR/issue-5153.rs:10:27
33
|
44
LL | trait Foo {
5-
| --------- this trait defines an item `foo`
5+
| --------- `Foo` defines an item `foo`
66
...
77
LL | (&5isize as &dyn Foo).foo();
88
| ^^^ method not found in `&dyn Foo`

src/test/ui/issues/issue-57362-1.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0599]: no method named `f` found for fn pointer `fn(&u8)` in the current
22
--> $DIR/issue-57362-1.rs:20:7
33
|
44
LL | trait Trait {
5-
| ----------- this trait defines an item `f`
5+
| ----------- `Trait` defines an item `f`
66
...
77
LL | a.f();
88
| ^ method not found in `fn(&u8)`

src/test/ui/issues/issue-57362-2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0599]: no function or associated item named `make_g` found for fn pointer
22
--> $DIR/issue-57362-2.rs:22:25
33
|
44
LL | trait X {
5-
| ------- this trait defines an item `make_g`
5+
| ------- `X` defines an item `make_g`
66
...
77
LL | let x = <fn (&())>::make_g();
88
| ^^^^^^ function or associated item not found in `for<'r> fn(&'r ())`

src/test/ui/never_type/issue-2149.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ error[E0599]: no method named `bind` found for array `[&str; 1]` in the current
1010
--> $DIR/issue-2149.rs:13:12
1111
|
1212
LL | trait VecMonad<A> {
13-
| ----------------- this trait defines an item `bind`
13+
| ----------------- `VecMonad` defines an item `bind`
1414
...
1515
LL | ["hi"].bind(|x| [x] );
1616
| ^^^^ method not found in `[&str; 1]`

src/test/ui/object-pointer-types.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0599]: no method named `owned` found for reference `&dyn Foo` in the curr
22
--> $DIR/object-pointer-types.rs:11:7
33
|
44
LL | trait Foo {
5-
| --------- this trait defines an item `owned`
5+
| --------- `Foo` defines an item `owned`
66
...
77
LL | x.owned();
88
| ^^^^^ method not found in `&dyn Foo`
@@ -13,7 +13,7 @@ error[E0599]: no method named `owned` found for mutable reference `&mut dyn Foo`
1313
--> $DIR/object-pointer-types.rs:17:7
1414
|
1515
LL | trait Foo {
16-
| --------- this trait defines an item `owned`
16+
| --------- `Foo` defines an item `owned`
1717
...
1818
LL | x.owned();
1919
| ^^^^^ method not found in `&mut dyn Foo`

src/test/ui/self/point-at-arbitrary-self-type-trait-method.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0599]: no method named `foo` found for struct `A` in the current scope
44
LL | trait B { fn foo(self: Box<Self>); }
55
| ------- --- the method is available for `std::boxed::Box<A>` here
66
| |
7-
| this trait defines an item `foo`
7+
| `B` defines an item `foo`
88
LL | struct A;
99
| --------- method `foo` not found for this
1010
...

src/test/ui/specialization/defaultimpl/specialization-trait-not-implemented.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0599]: no method named `foo_one` found for struct `MyStruct` in the curre
22
--> $DIR/specialization-trait-not-implemented.rs:22:29
33
|
44
LL | trait Foo {
5-
| --------- this trait defines an item `foo_one`
5+
| --------- `Foo` defines an item `foo_one`
66
...
77
LL | struct MyStruct;
88
| ----------------

src/test/ui/traits/trait-item-privacy.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | struct S;
55
| --------- method `a` not found for this
66
...
77
LL | trait A {
8-
| ------- this trait defines an item `a`
8+
| ------- `method::A` defines an item `a`
99
...
1010
LL | S.a();
1111
| ^ method not found in `S`
@@ -47,7 +47,7 @@ LL | struct S;
4747
| --------- function or associated item `a` not found for this
4848
...
4949
LL | trait A {
50-
| ------- this trait defines an item `a`
50+
| ------- `method::A` defines an item `a`
5151
...
5252
LL | S::a(&S);
5353
| ^ function or associated item not found in `S`
@@ -82,7 +82,7 @@ LL | struct S;
8282
| --------- associated item `A` not found for this
8383
...
8484
LL | trait A {
85-
| ------- this trait defines an item `A`
85+
| ------- `assoc_const::A` defines an item `A`
8686
...
8787
LL | S::A;
8888
| ^ associated item not found in `S`

src/test/ui/trivial-bounds/trivial-bounds-leak.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ error[E0599]: no method named `test` found for type `i32` in the current scope
1212
--> $DIR/trivial-bounds-leak.rs:24:10
1313
|
1414
LL | pub trait Foo {
15-
| ------------- this trait defines an item `test`
15+
| ------------- `Foo` defines an item `test`
1616
...
1717
LL | 3i32.test();
1818
| ^^^^ method not found in `i32`

0 commit comments

Comments
 (0)