Skip to content

Commit 824383d

Browse files
committed
Auto merge of #64237 - estebank:tweak-method-not-found, r=Centril
Give method not found a primary span label
2 parents 1e86913 + 5799fb4 commit 824383d

File tree

63 files changed

+101
-98
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+101
-98
lines changed

src/librustc_typeck/check/method/suggest.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
425425
"private field"
426426
};
427427
err.span_label(item_name.span, format!("{}, not a method", field_kind));
428+
} else if lev_candidate.is_none() && static_sources.is_empty() {
429+
err.span_label(span, format!("{} not found in `{}`", item_kind, ty_str));
430+
self.tcx.sess.trait_methods_not_found.borrow_mut().insert(orig_span);
428431
}
429432
} else {
430433
err.span_label(span, format!("{} not found in `{}`", item_kind, ty_str));

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ error[E0599]: no method named `test` found for type `std::vec::Vec<{integer}>` i
1212
--> $DIR/auto-ref-slice-plus-ref.rs:8:7
1313
|
1414
LL | a.test();
15-
| ^^^^
15+
| ^^^^ method not found in `std::vec::Vec<{integer}>`
1616
|
1717
= help: items from traits can only be used if the trait is implemented and in scope
1818
= note: the following trait defines an item `test`, perhaps you need to implement it:
@@ -22,7 +22,7 @@ error[E0599]: no method named `test` found for type `[{integer}; 1]` in the curr
2222
--> $DIR/auto-ref-slice-plus-ref.rs:10:11
2323
|
2424
LL | ([1]).test();
25-
| ^^^^
25+
| ^^^^ method not found in `[{integer}; 1]`
2626
|
2727
= help: items from traits can only be used if the trait is implemented and in scope
2828
= note: the following trait defines an item `test`, perhaps you need to implement it:
@@ -32,7 +32,7 @@ error[E0599]: no method named `test` found for type `&[{integer}; 1]` in the cur
3232
--> $DIR/auto-ref-slice-plus-ref.rs:11:12
3333
|
3434
LL | (&[1]).test();
35-
| ^^^^
35+
| ^^^^ method not found in `&[{integer}; 1]`
3636
|
3737
= help: items from traits can only be used if the trait is implemented and in scope
3838
= note: the following trait defines an item `test`, perhaps you need to implement it:

src/test/ui/class-cast-to-trait.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0599]: no method named `eat` found for type `std::boxed::Box<dyn Noisy>`
22
--> $DIR/class-cast-to-trait.rs:53:8
33
|
44
LL | nyan.eat();
5-
| ^^^
5+
| ^^^ method not found in `std::boxed::Box<dyn Noisy>`
66

77
error: aborting due to previous error
88

src/test/ui/coherence/coherence_inherent.old.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0599]: no method named `the_fn` found for type `&Lib::TheStruct` in the c
22
--> $DIR/coherence_inherent.rs:35:11
33
|
44
LL | s.the_fn();
5-
| ^^^^^^
5+
| ^^^^^^ method not found in `&Lib::TheStruct`
66
|
77
= help: items from traits can only be used if the trait is in scope
88
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:

src/test/ui/coherence/coherence_inherent.re.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0599]: no method named `the_fn` found for type `&Lib::TheStruct` in the c
22
--> $DIR/coherence_inherent.rs:35:11
33
|
44
LL | s.the_fn();
5-
| ^^^^^^
5+
| ^^^^^^ method not found in `&Lib::TheStruct`
66
|
77
= help: items from traits can only be used if the trait is in scope
88
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:

src/test/ui/coherence/coherence_inherent_cc.old.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0599]: no method named `the_fn` found for type `&coherence_inherent_cc_li
22
--> $DIR/coherence_inherent_cc.rs:26:11
33
|
44
LL | s.the_fn();
5-
| ^^^^^^
5+
| ^^^^^^ method not found in `&coherence_inherent_cc_lib::TheStruct`
66
|
77
= help: items from traits can only be used if the trait is in scope
88
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:

src/test/ui/coherence/coherence_inherent_cc.re.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0599]: no method named `the_fn` found for type `&coherence_inherent_cc_li
22
--> $DIR/coherence_inherent_cc.rs:26:11
33
|
44
LL | s.the_fn();
5-
| ^^^^^^
5+
| ^^^^^^ method not found in `&coherence_inherent_cc_lib::TheStruct`
66
|
77
= help: items from traits can only be used if the trait is in scope
88
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:

src/test/ui/const-generics/invalid-const-arg-for-type-param.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LL | struct S;
1111
| --------- method `f` not found for this
1212
...
1313
LL | S.f::<0>();
14-
| ^
14+
| ^ method not found in `S`
1515

1616
error[E0107]: wrong number of const arguments: expected 0, found 1
1717
--> $DIR/invalid-const-arg-for-type-param.rs:8:9

src/test/ui/copy-a-resource.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | struct Foo {
55
| ---------- method `clone` not found for this
66
...
77
LL | let _y = x.clone();
8-
| ^^^^^
8+
| ^^^^^ method not found in `Foo`
99
|
1010
= help: items from traits can only be used if the trait is implemented and in scope
1111
= note: the following trait defines an item `clone`, perhaps you need to implement it:

src/test/ui/derives/derive-assoc-type-not-impl.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | struct Bar<T: Foo> {
55
| ------------------ method `clone` not found for this
66
...
77
LL | Bar::<NotClone> { x: 1 }.clone();
8-
| ^^^^^
8+
| ^^^^^ method not found in `Bar<NotClone>`
99
|
1010
= note: the method `clone` exists but the following trait bounds were not satisfied:
1111
`Bar<NotClone> : std::clone::Clone`

0 commit comments

Comments
 (0)