mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-15 21:47:04 +00:00
Make missing impl item suggestions more obvious that they're missing
This commit is contained in:
parent
204c516293
commit
73038d3a64
@ -466,10 +466,10 @@ fn suggestion_signature<'tcx>(
|
||||
assoc,
|
||||
)
|
||||
}
|
||||
ty::AssocKind::Type => format!("type {} = Type;", assoc.name),
|
||||
ty::AssocKind::Type => format!("type {} = /* Type */;", assoc.name),
|
||||
ty::AssocKind::Const => {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ error[E0046]: not all trait items implemented, missing: `Error`, `try_from`
|
||||
LL | impl TryFrom<OtherStream> for MyStream {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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!() }`
|
||||
|
||||
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
|
||||
|
|
||||
= 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 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!() }`
|
||||
|
@ -4,7 +4,7 @@ error[E0046]: not all trait items implemented, missing: `Item`
|
||||
LL | impl Iterator for Recurrence {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
|
||||
|
||||
|
@ -4,7 +4,7 @@ error[E0046]: not all trait items implemented, missing: `Output`
|
||||
LL | impl<C: Component> FnOnce<(C,)> for Prototype {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
|
||||
|
||||
|
@ -4,7 +4,7 @@ error[E0046]: not all trait items implemented, missing: `Target`
|
||||
LL | impl Deref for Thing {
|
||||
| ^^^^^^^^^^^^^^^^^^^^ 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
|
||||
|
||||
|
@ -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
|
||||
trait TraitB {
|
||||
type Item;
|
||||
}
|
||||
// aux-build:missing-assoc-fn-applicable-suggestions.rs
|
||||
|
||||
trait TraitA<A> {
|
||||
type Type;
|
||||
fn bar<T>(_: T) -> Self;
|
||||
fn baz<T>(_: T) -> Self where T: TraitB, <T as TraitB>::Item: Copy;
|
||||
}
|
||||
extern crate missing_assoc_fn_applicable_suggestions;
|
||||
use missing_assoc_fn_applicable_suggestions::TraitA;
|
||||
|
||||
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() {}
|
||||
|
@ -1,15 +1,13 @@
|
||||
error[E0046]: not all trait items implemented, missing: `Type`, `bar`, `baz`
|
||||
--> $DIR/missing-assoc-fn-applicable-suggestions.rs:15:1
|
||||
error[E0046]: not all trait items implemented, missing: `Type`, `bar`, `baz`, `A`
|
||||
--> $DIR/missing-assoc-fn-applicable-suggestions.rs:7:1
|
||||
|
|
||||
LL | type Type;
|
||||
| --------- `Type` from trait
|
||||
LL | fn bar<T>(_: T) -> Self;
|
||||
| ------------------------ `bar` from trait
|
||||
LL | fn baz<T>(_: T) -> Self where T: TraitB, <T as TraitB>::Item: Copy;
|
||||
| ------------------------------------------------------------------- `baz` from trait
|
||||
...
|
||||
LL | impl TraitA<()> for S {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ missing `Type`, `bar`, `baz` in implementation
|
||||
LL | impl TraitA<()> for S {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ missing `Type`, `bar`, `baz`, `A` in implementation
|
||||
|
|
||||
= 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;`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user