Make missing impl item suggestions more obvious that they're missing
This commit is contained in:
parent
204c516293
commit
73038d3a64
10 changed files with 41 additions and 51 deletions
|
@ -466,10 +466,10 @@ fn suggestion_signature<'tcx>(
|
||||||
assoc,
|
assoc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
ty::AssocKind::Type => format!("type {} = Type;", assoc.name),
|
ty::AssocKind::Type => format!("type {} = /* Type */;", assoc.name),
|
||||||
ty::AssocKind::Const => {
|
ty::AssocKind::Const => {
|
||||||
let ty = tcx.type_of(assoc.def_id).subst_identity();
|
let ty = tcx.type_of(assoc.def_id).subst_identity();
|
||||||
let val = ty_kind_suggestion(ty).unwrap_or("value");
|
let val = ty_kind_suggestion(ty).unwrap_or("todo!()");
|
||||||
format!("const {}: {} = {};", assoc.name, ty, val)
|
format!("const {}: {} = {};", assoc.name, ty, val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ error[E0046]: not all trait items implemented, missing: `Error`, `try_from`
|
||||||
LL | impl TryFrom<OtherStream> for MyStream {}
|
LL | impl TryFrom<OtherStream> for MyStream {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Error`, `try_from` in implementation
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Error`, `try_from` in implementation
|
||||||
|
|
|
|
||||||
= help: implement the missing item: `type Error = Type;`
|
= help: implement the missing item: `type Error = /* Type */;`
|
||||||
= help: implement the missing item: `fn try_from(_: OtherStream) -> Result<Self, <Self as TryFrom<OtherStream>>::Error> { todo!() }`
|
= help: implement the missing item: `fn try_from(_: OtherStream) -> Result<Self, <Self as TryFrom<OtherStream>>::Error> { todo!() }`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
|
@ -5,7 +5,7 @@ LL | impl m1::X for X {
|
||||||
| ^^^^^^^^^^^^^^^^ missing `CONSTANT`, `Type`, `method`, `method2`, `method3`, `method4`, `method5` in implementation
|
| ^^^^^^^^^^^^^^^^ missing `CONSTANT`, `Type`, `method`, `method2`, `method3`, `method4`, `method5` in implementation
|
||||||
|
|
|
|
||||||
= help: implement the missing item: `const CONSTANT: u32 = 42;`
|
= help: implement the missing item: `const CONSTANT: u32 = 42;`
|
||||||
= help: implement the missing item: `type Type = Type;`
|
= help: implement the missing item: `type Type = /* Type */;`
|
||||||
= help: implement the missing item: `fn method(&self, _: String) -> <Self as m1::X>::Type { todo!() }`
|
= help: implement the missing item: `fn method(&self, _: String) -> <Self as m1::X>::Type { todo!() }`
|
||||||
= help: implement the missing item: `fn method2(self: Box<Self>, _: String) -> <Self as m1::X>::Type { todo!() }`
|
= help: implement the missing item: `fn method2(self: Box<Self>, _: String) -> <Self as m1::X>::Type { todo!() }`
|
||||||
= help: implement the missing item: `fn method3(_: &Self, _: String) -> <Self as m1::X>::Type { todo!() }`
|
= help: implement the missing item: `fn method3(_: &Self, _: String) -> <Self as m1::X>::Type { todo!() }`
|
||||||
|
|
|
@ -4,7 +4,7 @@ error[E0046]: not all trait items implemented, missing: `Item`
|
||||||
LL | impl Iterator for Recurrence {
|
LL | impl Iterator for Recurrence {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Item` in implementation
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Item` in implementation
|
||||||
|
|
|
|
||||||
= help: implement the missing item: `type Item = Type;`
|
= help: implement the missing item: `type Item = /* Type */;`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ error[E0046]: not all trait items implemented, missing: `Output`
|
||||||
LL | impl<C: Component> FnOnce<(C,)> for Prototype {
|
LL | impl<C: Component> FnOnce<(C,)> for Prototype {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Output` in implementation
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Output` in implementation
|
||||||
|
|
|
|
||||||
= help: implement the missing item: `type Output = Type;`
|
= help: implement the missing item: `type Output = /* Type */;`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ error[E0046]: not all trait items implemented, missing: `Target`
|
||||||
LL | impl Deref for Thing {
|
LL | impl Deref for Thing {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^ missing `Target` in implementation
|
| ^^^^^^^^^^^^^^^^^^^^ missing `Target` in implementation
|
||||||
|
|
|
|
||||||
= help: implement the missing item: `type Target = Type;`
|
= help: implement the missing item: `type Target = /* Type */;`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
pub trait TraitB {
|
||||||
|
type Item;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait TraitA<A> {
|
||||||
|
type Type;
|
||||||
|
|
||||||
|
fn bar<T>(_: T) -> Self;
|
||||||
|
|
||||||
|
fn baz<T>(_: T) -> Self
|
||||||
|
where
|
||||||
|
T: TraitB,
|
||||||
|
<T as TraitB>::Item: Copy;
|
||||||
|
|
||||||
|
const A: usize;
|
||||||
|
}
|
|
@ -1,21 +0,0 @@
|
||||||
// run-rustfix
|
|
||||||
trait TraitB {
|
|
||||||
type Item;
|
|
||||||
}
|
|
||||||
|
|
||||||
trait TraitA<A> {
|
|
||||||
type Type;
|
|
||||||
fn bar<T>(_: T) -> Self;
|
|
||||||
fn baz<T>(_: T) -> Self where T: TraitB, <T as TraitB>::Item: Copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct S;
|
|
||||||
struct Type;
|
|
||||||
|
|
||||||
impl TraitA<()> for S { //~ ERROR not all trait items implemented
|
|
||||||
fn baz<T>(_: T) -> Self where T: TraitB, <T as TraitB>::Item: Copy { todo!() }
|
|
||||||
fn bar<T>(_: T) -> Self { todo!() }
|
|
||||||
type Type = Type;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
|
@ -1,18 +1,15 @@
|
||||||
// run-rustfix
|
// aux-build:missing-assoc-fn-applicable-suggestions.rs
|
||||||
trait TraitB {
|
|
||||||
type Item;
|
|
||||||
}
|
|
||||||
|
|
||||||
trait TraitA<A> {
|
extern crate missing_assoc_fn_applicable_suggestions;
|
||||||
type Type;
|
use missing_assoc_fn_applicable_suggestions::TraitA;
|
||||||
fn bar<T>(_: T) -> Self;
|
|
||||||
fn baz<T>(_: T) -> Self where T: TraitB, <T as TraitB>::Item: Copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct S;
|
struct S;
|
||||||
struct Type;
|
impl TraitA<()> for S {
|
||||||
|
//~^ ERROR not all trait items implemented
|
||||||
impl TraitA<()> for S { //~ ERROR not all trait items implemented
|
|
||||||
}
|
}
|
||||||
|
//~^ HELP implement the missing item: `type Type = /* Type */;`
|
||||||
|
//~| HELP implement the missing item: `fn bar<T>(_: T) -> Self { todo!() }`
|
||||||
|
//~| HELP implement the missing item: `fn baz<T>(_: T) -> Self where T: TraitB, <T as TraitB>::Item: Copy { todo!() }`
|
||||||
|
//~| HELP implement the missing item: `const A: usize = 42;`
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
error[E0046]: not all trait items implemented, missing: `Type`, `bar`, `baz`
|
error[E0046]: not all trait items implemented, missing: `Type`, `bar`, `baz`, `A`
|
||||||
--> $DIR/missing-assoc-fn-applicable-suggestions.rs:15:1
|
--> $DIR/missing-assoc-fn-applicable-suggestions.rs:7:1
|
||||||
|
|
|
|
||||||
LL | type Type;
|
LL | impl TraitA<()> for S {
|
||||||
| --------- `Type` from trait
|
| ^^^^^^^^^^^^^^^^^^^^^ missing `Type`, `bar`, `baz`, `A` in implementation
|
||||||
LL | fn bar<T>(_: T) -> Self;
|
|
|
||||||
| ------------------------ `bar` from trait
|
= help: implement the missing item: `type Type = /* Type */;`
|
||||||
LL | fn baz<T>(_: T) -> Self where T: TraitB, <T as TraitB>::Item: Copy;
|
= help: implement the missing item: `fn bar<T>(_: T) -> Self { todo!() }`
|
||||||
| ------------------------------------------------------------------- `baz` from trait
|
= help: implement the missing item: `fn baz<T>(_: T) -> Self where T: TraitB, <T as TraitB>::Item: Copy { todo!() }`
|
||||||
...
|
= help: implement the missing item: `const A: usize = 42;`
|
||||||
LL | impl TraitA<()> for S {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^ missing `Type`, `bar`, `baz` in implementation
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue