diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index af7f63772c3..7e98797d0c2 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -988,6 +988,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let action = if let Some(param) = param_type { format!("restrict type parameter `{}` with", param) } else { + // FIXME: it might only need to be imported into scope, not implemented. "implement".to_string() }; let mut use_note = true; @@ -996,9 +997,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.span_label( self.tcx.sess.source_map().def_span(span), &format!( - "`{}` defines an item `{}`", + "`{}` defines an item `{}`, perhaps you need to {} it", self.tcx.def_path_str(trait_info.def_id), - item_name + item_name, + action ), ); use_note = false diff --git a/src/test/ui/associated-const/associated-const-no-item.stderr b/src/test/ui/associated-const/associated-const-no-item.stderr index 02d4866e3f5..c3339e453e8 100644 --- a/src/test/ui/associated-const/associated-const-no-item.stderr +++ b/src/test/ui/associated-const/associated-const-no-item.stderr @@ -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 { - | --------- `Foo` defines an item `ID` + | --------- `Foo` defines an item `ID`, perhaps you need to implement it ... LL | const X: i32 = ::ID; | ^^ associated item not found in `i32` diff --git a/src/test/ui/auto-ref-slice-plus-ref.stderr b/src/test/ui/auto-ref-slice-plus-ref.stderr index 26b2c44fdd9..3500cef6c39 100644 --- a/src/test/ui/auto-ref-slice-plus-ref.stderr +++ b/src/test/ui/auto-ref-slice-plus-ref.stderr @@ -5,7 +5,7 @@ LL | a.test_mut(); | ^^^^^^^^ help: there is a method with a similar name: `get_mut` ... LL | trait MyIter { - | ------------ `MyIter` defines an item `test_mut` + | ------------ `MyIter` defines an item `test_mut`, perhaps you need to implement it | = 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 { - | ------------ `MyIter` defines an item `test` + | ------------ `MyIter` defines an item `test`, perhaps you need to implement it | = 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 { - | ------------ `MyIter` defines an item `test` + | ------------ `MyIter` defines an item `test`, perhaps you need to implement it | = 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 { - | ------------ `MyIter` defines an item `test` + | ------------ `MyIter` defines an item `test`, perhaps you need to implement it | = help: items from traits can only be used if the trait is implemented and in scope diff --git a/src/test/ui/impl-trait/issues/issue-21659-show-relevant-trait-impls-3.stderr b/src/test/ui/impl-trait/issues/issue-21659-show-relevant-trait-impls-3.stderr index cdcf84a7063..75a2e9a99a9 100644 --- a/src/test/ui/impl-trait/issues/issue-21659-show-relevant-trait-impls-3.stderr +++ b/src/test/ui/impl-trait/issues/issue-21659-show-relevant-trait-impls-3.stderr @@ -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 { - | ------------ `Foo` defines an item `foo` + | ------------ `Foo` defines an item `foo`, perhaps you need to implement it ... LL | struct Bar; | ----------- method `foo` not found for this diff --git a/src/test/ui/impl-trait/no-method-suggested-traits.stderr b/src/test/ui/impl-trait/no-method-suggested-traits.stderr index b3da4a6ead6..c6017a5fea1 100644 --- a/src/test/ui/impl-trait/no-method-suggested-traits.stderr +++ b/src/test/ui/impl-trait/no-method-suggested-traits.stderr @@ -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 { - | ------------- `foo::Bar` defines an item `method2` + | ------------- `foo::Bar` defines an item `method2`, perhaps you need to implement it ... 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 { - | ------------- `foo::Bar` defines an item `method2` + | ------------- `foo::Bar` defines an item `method2`, perhaps you need to implement it ... 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 { - | ------------- `foo::Bar` defines an item `method2` + | ------------- `foo::Bar` defines an item `method2`, perhaps you need to implement it ... 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 { - | ------------- `foo::Bar` defines an item `method2` + | ------------- `foo::Bar` defines an item `method2`, perhaps you need to implement it ... 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 { - | ------------- `foo::Bar` defines an item `method2` + | ------------- `foo::Bar` defines an item `method2`, perhaps you need to implement it ... 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 { - | ------------- `foo::Bar` defines an item `method2` + | ------------- `foo::Bar` defines an item `method2`, perhaps you need to implement it ... 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>>` diff --git a/src/test/ui/issues/issue-5153.stderr b/src/test/ui/issues/issue-5153.stderr index bf48c662383..44ef73550f8 100644 --- a/src/test/ui/issues/issue-5153.stderr +++ b/src/test/ui/issues/issue-5153.stderr @@ -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 { - | --------- `Foo` defines an item `foo` + | --------- `Foo` defines an item `foo`, perhaps you need to implement it ... LL | (&5isize as &dyn Foo).foo(); | ^^^ method not found in `&dyn Foo` diff --git a/src/test/ui/issues/issue-57362-1.stderr b/src/test/ui/issues/issue-57362-1.stderr index 4eaa5adbea4..c48f51e2b2a 100644 --- a/src/test/ui/issues/issue-57362-1.stderr +++ b/src/test/ui/issues/issue-57362-1.stderr @@ -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 { - | ----------- `Trait` defines an item `f` + | ----------- `Trait` defines an item `f`, perhaps you need to implement it ... LL | a.f(); | ^ method not found in `fn(&u8)` diff --git a/src/test/ui/issues/issue-57362-2.stderr b/src/test/ui/issues/issue-57362-2.stderr index ce689334cc1..b3b30dbd1c8 100644 --- a/src/test/ui/issues/issue-57362-2.stderr +++ b/src/test/ui/issues/issue-57362-2.stderr @@ -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 { - | ------- `X` defines an item `make_g` + | ------- `X` defines an item `make_g`, perhaps you need to implement it ... LL | let x = ::make_g(); | ^^^^^^ function or associated item not found in `for<'r> fn(&'r ())` diff --git a/src/test/ui/never_type/issue-2149.stderr b/src/test/ui/never_type/issue-2149.stderr index b92ab5dde27..74512619966 100644 --- a/src/test/ui/never_type/issue-2149.stderr +++ b/src/test/ui/never_type/issue-2149.stderr @@ -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 { - | ----------------- `VecMonad` defines an item `bind` + | ----------------- `VecMonad` defines an item `bind`, perhaps you need to implement it ... LL | ["hi"].bind(|x| [x] ); | ^^^^ method not found in `[&str; 1]` diff --git a/src/test/ui/object-pointer-types.stderr b/src/test/ui/object-pointer-types.stderr index 7364ead97f6..07b7da94097 100644 --- a/src/test/ui/object-pointer-types.stderr +++ b/src/test/ui/object-pointer-types.stderr @@ -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 { - | --------- `Foo` defines an item `owned` + | --------- `Foo` defines an item `owned`, perhaps you need to implement it ... 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 { - | --------- `Foo` defines an item `owned` + | --------- `Foo` defines an item `owned`, perhaps you need to implement it ... LL | x.owned(); | ^^^^^ method not found in `&mut dyn Foo` diff --git a/src/test/ui/self/point-at-arbitrary-self-type-trait-method.stderr b/src/test/ui/self/point-at-arbitrary-self-type-trait-method.stderr index fefa6dab15a..999bbcca6bc 100644 --- a/src/test/ui/self/point-at-arbitrary-self-type-trait-method.stderr +++ b/src/test/ui/self/point-at-arbitrary-self-type-trait-method.stderr @@ -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); } | ------- --- the method is available for `std::boxed::Box` here | | - | `B` defines an item `foo` + | `B` defines an item `foo`, perhaps you need to implement it LL | struct A; | --------- method `foo` not found for this ... diff --git a/src/test/ui/specialization/defaultimpl/specialization-trait-not-implemented.stderr b/src/test/ui/specialization/defaultimpl/specialization-trait-not-implemented.stderr index 93a5f3051fe..f4d29e61cc1 100644 --- a/src/test/ui/specialization/defaultimpl/specialization-trait-not-implemented.stderr +++ b/src/test/ui/specialization/defaultimpl/specialization-trait-not-implemented.stderr @@ -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 { - | --------- `Foo` defines an item `foo_one` + | --------- `Foo` defines an item `foo_one`, perhaps you need to implement it ... LL | struct MyStruct; | ---------------- diff --git a/src/test/ui/traits/trait-item-privacy.stderr b/src/test/ui/traits/trait-item-privacy.stderr index 23f08f37826..f893456a17c 100644 --- a/src/test/ui/traits/trait-item-privacy.stderr +++ b/src/test/ui/traits/trait-item-privacy.stderr @@ -5,7 +5,7 @@ LL | struct S; | --------- method `a` not found for this ... LL | trait A { - | ------- `method::A` defines an item `a` + | ------- `method::A` defines an item `a`, perhaps you need to implement it ... 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 { - | ------- `method::A` defines an item `a` + | ------- `method::A` defines an item `a`, perhaps you need to implement it ... 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 { - | ------- `assoc_const::A` defines an item `A` + | ------- `assoc_const::A` defines an item `A`, perhaps you need to implement it ... LL | S::A; | ^ associated item not found in `S` diff --git a/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr b/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr index 0bd18763ac9..ef41c0e5fa0 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr +++ b/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr @@ -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 { - | ------------- `Foo` defines an item `test` + | ------------- `Foo` defines an item `test`, perhaps you need to implement it ... LL | 3i32.test(); | ^^^^ method not found in `i32`