Skip to content

Give method not found a primary span label #64237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/librustc_typeck/check/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
"private field"
};
err.span_label(item_name.span, format!("{}, not a method", field_kind));
} else if lev_candidate.is_none() && static_sources.is_empty() {
err.span_label(span, format!("{} not found in `{}`", item_kind, ty_str));
self.tcx.sess.trait_methods_not_found.borrow_mut().insert(orig_span);
}
} else {
err.span_label(span, format!("{} not found in `{}`", item_kind, ty_str));
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/auto-ref-slice-plus-ref.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ error[E0599]: no method named `test` found for type `std::vec::Vec<{integer}>` i
--> $DIR/auto-ref-slice-plus-ref.rs:8:7
|
LL | a.test();
| ^^^^
| ^^^^ method not found in `std::vec::Vec<{integer}>`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `test`, perhaps you need to implement it:
Expand All @@ -22,7 +22,7 @@ error[E0599]: no method named `test` found for type `[{integer}; 1]` in the curr
--> $DIR/auto-ref-slice-plus-ref.rs:10:11
|
LL | ([1]).test();
| ^^^^
| ^^^^ method not found in `[{integer}; 1]`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `test`, perhaps you need to implement it:
Expand All @@ -32,7 +32,7 @@ error[E0599]: no method named `test` found for type `&[{integer}; 1]` in the cur
--> $DIR/auto-ref-slice-plus-ref.rs:11:12
|
LL | (&[1]).test();
| ^^^^
| ^^^^ method not found in `&[{integer}; 1]`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `test`, perhaps you need to implement it:
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/class-cast-to-trait.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0599]: no method named `eat` found for type `std::boxed::Box<dyn Noisy>`
--> $DIR/class-cast-to-trait.rs:53:8
|
LL | nyan.eat();
| ^^^
| ^^^ method not found in `std::boxed::Box<dyn Noisy>`

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/coherence/coherence_inherent.old.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0599]: no method named `the_fn` found for type `&Lib::TheStruct` in the c
--> $DIR/coherence_inherent.rs:35:11
|
LL | s.the_fn();
| ^^^^^^
| ^^^^^^ method not found in `&Lib::TheStruct`
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/coherence/coherence_inherent.re.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0599]: no method named `the_fn` found for type `&Lib::TheStruct` in the c
--> $DIR/coherence_inherent.rs:35:11
|
LL | s.the_fn();
| ^^^^^^
| ^^^^^^ method not found in `&Lib::TheStruct`
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/coherence/coherence_inherent_cc.old.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0599]: no method named `the_fn` found for type `&coherence_inherent_cc_li
--> $DIR/coherence_inherent_cc.rs:26:11
|
LL | s.the_fn();
| ^^^^^^
| ^^^^^^ method not found in `&coherence_inherent_cc_lib::TheStruct`
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/coherence/coherence_inherent_cc.re.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0599]: no method named `the_fn` found for type `&coherence_inherent_cc_li
--> $DIR/coherence_inherent_cc.rs:26:11
|
LL | s.the_fn();
| ^^^^^^
| ^^^^^^ method not found in `&coherence_inherent_cc_lib::TheStruct`
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LL | struct S;
| --------- method `f` not found for this
...
LL | S.f::<0>();
| ^
| ^ method not found in `S`

error[E0107]: wrong number of const arguments: expected 0, found 1
--> $DIR/invalid-const-arg-for-type-param.rs:8:9
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/copy-a-resource.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | struct Foo {
| ---------- method `clone` not found for this
...
LL | let _y = x.clone();
| ^^^^^
| ^^^^^ method not found in `Foo`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `clone`, perhaps you need to implement it:
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/derives/derive-assoc-type-not-impl.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | struct Bar<T: Foo> {
| ------------------ method `clone` not found for this
...
LL | Bar::<NotClone> { x: 1 }.clone();
| ^^^^^
| ^^^^^ method not found in `Bar<NotClone>`
|
= note: the method `clone` exists but the following trait bounds were not satisfied:
`Bar<NotClone> : std::clone::Clone`
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/error-festival.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ error[E0599]: no method named `z` found for type `&str` in the current scope
--> $DIR/error-festival.rs:16:7
|
LL | x.z();
| ^
| ^ method not found in `&str`

error[E0600]: cannot apply unary operator `!` to type `Question`
--> $DIR/error-festival.rs:19:5
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/hygiene/no_implicit_prelude.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ LL | fn f() { ::bar::m!(); }
| ------------ in this macro invocation
...
LL | ().clone()
| ^^^^^
| ^^^^^ method not found in `()`
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/hygiene/trait_items.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | fn f() { ::baz::m!(); }
| ------------ in this macro invocation
...
LL | pub macro m() { ().f() }
| ^
| ^ method not found in `()`
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/impl-trait/bindings-opaque.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ error[E0599]: no method named `count_ones` found for type `impl std::marker::Cop
--> $DIR/bindings-opaque.rs:11:17
|
LL | let _ = FOO.count_ones();
| ^^^^^^^^^^
| ^^^^^^^^^^ method not found in `impl std::marker::Copy`

error[E0599]: no method named `count_ones` found for type `impl std::marker::Copy` in the current scope
--> $DIR/bindings-opaque.rs:13:17
|
LL | let _ = BAR.count_ones();
| ^^^^^^^^^^
| ^^^^^^^^^^ method not found in `impl std::marker::Copy`

error[E0599]: no method named `count_ones` found for type `impl std::marker::Copy` in the current scope
--> $DIR/bindings-opaque.rs:15:17
|
LL | let _ = foo.count_ones();
| ^^^^^^^^^^
| ^^^^^^^^^^ method not found in `impl std::marker::Copy`

error: aborting due to 3 previous errors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | struct Bar;
| ----------- method `foo` not found for this
...
LL | f1.foo(1usize);
| ^^^
| ^^^ method not found in `Bar`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `foo`, perhaps you need to implement it:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | struct Foo;
| ----------- method `is_empty` not found for this
...
LL | foo(|s| s.is_empty());
| ^^^^^^^^
| ^^^^^^^^ method not found in `Foo`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `is_empty`, perhaps you need to implement it:
Expand Down
48 changes: 24 additions & 24 deletions src/test/ui/impl-trait/no-method-suggested-traits.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0599]: no method named `method` found for type `u32` in the current scope
--> $DIR/no-method-suggested-traits.rs:23:10
|
LL | 1u32.method();
| ^^^^^^
| ^^^^^^ method not found in `u32`
|
= help: items from traits can only be used if the trait is in scope
help: the following traits are implemented but not in scope, perhaps add a `use` for one of them:
Expand All @@ -20,7 +20,7 @@ error[E0599]: no method named `method` found for type `std::rc::Rc<&mut std::box
--> $DIR/no-method-suggested-traits.rs:26:44
|
LL | std::rc::Rc::new(&mut Box::new(&1u32)).method();
| ^^^^^^
| ^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&u32>>`
|
= help: items from traits can only be used if the trait is in scope
help: the following traits are implemented but not in scope, perhaps add a `use` for one of them:
Expand All @@ -38,7 +38,7 @@ error[E0599]: no method named `method` found for type `char` in the current scop
--> $DIR/no-method-suggested-traits.rs:30:9
|
LL | 'a'.method();
| ^^^^^^
| ^^^^^^ method not found in `char`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
Expand All @@ -58,7 +58,7 @@ LL | fn method(&self) {}
| the method is available for `std::rc::Rc<std::rc::Rc<&mut std::boxed::Box<&char>>>` here
...
LL | std::rc::Rc::new(&mut Box::new(&'a')).method();
| ^^^^^^
| ^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&char>>`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
Expand All @@ -70,7 +70,7 @@ error[E0599]: no method named `method` found for type `i32` in the current scope
--> $DIR/no-method-suggested-traits.rs:35:10
|
LL | 1i32.method();
| ^^^^^^
| ^^^^^^ method not found in `i32`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
Expand All @@ -82,7 +82,7 @@ error[E0599]: no method named `method` found for type `std::rc::Rc<&mut std::box
--> $DIR/no-method-suggested-traits.rs:37:44
|
LL | std::rc::Rc::new(&mut Box::new(&1i32)).method();
| ^^^^^^
| ^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&i32>>`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
Expand All @@ -97,7 +97,7 @@ LL | struct Foo;
| ----------- method `method` not found for this
...
LL | Foo.method();
| ^^^^^^
| ^^^^^^ method not found in `Foo`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following traits define an item `method`, perhaps you need to implement one of them:
Expand All @@ -110,7 +110,7 @@ error[E0599]: no method named `method` found for type `std::rc::Rc<&mut std::box
--> $DIR/no-method-suggested-traits.rs:42:43
|
LL | std::rc::Rc::new(&mut Box::new(&Foo)).method();
| ^^^^^^
| ^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&Foo>>`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following traits define an item `method`, perhaps you need to implement one of them:
Expand All @@ -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 | 1u64.method2();
| ^^^^^^^
| ^^^^^^^ method not found in `u64`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `method2`, perhaps you need to implement it:
Expand All @@ -133,7 +133,7 @@ error[E0599]: no method named `method2` found for type `std::rc::Rc<&mut std::bo
--> $DIR/no-method-suggested-traits.rs:47:44
|
LL | std::rc::Rc::new(&mut Box::new(&1u64)).method2();
| ^^^^^^^
| ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&u64>>`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `method2`, perhaps you need to implement it:
Expand All @@ -143,7 +143,7 @@ error[E0599]: no method named `method2` found for type `no_method_suggested_trai
--> $DIR/no-method-suggested-traits.rs:50:37
|
LL | no_method_suggested_traits::Foo.method2();
| ^^^^^^^
| ^^^^^^^ method not found in `no_method_suggested_traits::Foo`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `method2`, perhaps you need to implement it:
Expand All @@ -153,7 +153,7 @@ error[E0599]: no method named `method2` found for type `std::rc::Rc<&mut std::bo
--> $DIR/no-method-suggested-traits.rs:52:71
|
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>>`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `method2`, perhaps you need to implement it:
Expand All @@ -163,7 +163,7 @@ error[E0599]: no method named `method2` found for type `no_method_suggested_trai
--> $DIR/no-method-suggested-traits.rs:54:40
|
LL | no_method_suggested_traits::Bar::X.method2();
| ^^^^^^^
| ^^^^^^^ method not found in `no_method_suggested_traits::Bar`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `method2`, perhaps you need to implement it:
Expand All @@ -173,7 +173,7 @@ error[E0599]: no method named `method2` found for type `std::rc::Rc<&mut std::bo
--> $DIR/no-method-suggested-traits.rs:56:74
|
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>>`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `method2`, perhaps you need to implement it:
Expand All @@ -186,7 +186,7 @@ LL | struct Foo;
| ----------- method `method3` not found for this
...
LL | Foo.method3();
| ^^^^^^^
| ^^^^^^^ method not found in `Foo`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `method3`, perhaps you need to implement it:
Expand All @@ -196,7 +196,7 @@ error[E0599]: no method named `method3` found for type `std::rc::Rc<&mut std::bo
--> $DIR/no-method-suggested-traits.rs:61:43
|
LL | std::rc::Rc::new(&mut Box::new(&Foo)).method3();
| ^^^^^^^
| ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&Foo>>`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `method3`, perhaps you need to implement it:
Expand All @@ -209,7 +209,7 @@ LL | enum Bar { X }
| -------- method `method3` not found for this
...
LL | Bar::X.method3();
| ^^^^^^^
| ^^^^^^^ method not found in `Bar`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `method3`, perhaps you need to implement it:
Expand All @@ -219,7 +219,7 @@ error[E0599]: no method named `method3` found for type `std::rc::Rc<&mut std::bo
--> $DIR/no-method-suggested-traits.rs:65:46
|
LL | std::rc::Rc::new(&mut Box::new(&Bar::X)).method3();
| ^^^^^^^
| ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&Bar>>`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `method3`, perhaps you need to implement it:
Expand All @@ -229,37 +229,37 @@ error[E0599]: no method named `method3` found for type `usize` in the current sc
--> $DIR/no-method-suggested-traits.rs:69:13
|
LL | 1_usize.method3();
| ^^^^^^^
| ^^^^^^^ method not found in `usize`

error[E0599]: no method named `method3` found for type `std::rc::Rc<&mut std::boxed::Box<&usize>>` in the current scope
--> $DIR/no-method-suggested-traits.rs:70:47
|
LL | std::rc::Rc::new(&mut Box::new(&1_usize)).method3();
| ^^^^^^^
| ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&usize>>`

error[E0599]: no method named `method3` found for type `no_method_suggested_traits::Foo` in the current scope
--> $DIR/no-method-suggested-traits.rs:71:37
|
LL | no_method_suggested_traits::Foo.method3();
| ^^^^^^^
| ^^^^^^^ method not found in `no_method_suggested_traits::Foo`

error[E0599]: no method named `method3` found for type `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Foo>>` in the current scope
--> $DIR/no-method-suggested-traits.rs:72:71
|
LL | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).method3();
| ^^^^^^^
| ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Foo>>`

error[E0599]: no method named `method3` found for type `no_method_suggested_traits::Bar` in the current scope
--> $DIR/no-method-suggested-traits.rs:74:40
|
LL | no_method_suggested_traits::Bar::X.method3();
| ^^^^^^^
| ^^^^^^^ method not found in `no_method_suggested_traits::Bar`

error[E0599]: no method named `method3` found for type `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Bar>>` in the current scope
--> $DIR/no-method-suggested-traits.rs:75:74
|
LL | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Bar::X)).method3();
| ^^^^^^^
| ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Bar>>`

error: aborting due to 24 previous errors

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/infinite/infinite-autoderef.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ LL | struct Foo;
| ----------- method `bar` not found for this
...
LL | Foo.bar();
| ^^^
| ^^^ method not found in `Foo`

error: aborting due to 6 previous errors

Expand Down
Loading