Format missing GATs correctly
This commit is contained in:
parent
73038d3a64
commit
f362f6e9e6
5 changed files with 35 additions and 2 deletions
|
@ -466,7 +466,13 @@ fn suggestion_signature<'tcx>(
|
||||||
assoc,
|
assoc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
ty::AssocKind::Type => format!("type {} = /* Type */;", assoc.name),
|
ty::AssocKind::Type => {
|
||||||
|
let (generics, where_clauses) = bounds_from_generic_predicates(
|
||||||
|
tcx,
|
||||||
|
tcx.predicates_of(assoc.def_id).instantiate_own(tcx, substs),
|
||||||
|
);
|
||||||
|
format!("type {}{generics} = /* Type */{where_clauses};", 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("todo!()");
|
let val = ty_kind_suggestion(ty).unwrap_or("todo!()");
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
pub trait Foo {
|
||||||
|
type Gat<T>
|
||||||
|
where
|
||||||
|
T: std::fmt::Display;
|
||||||
|
}
|
11
tests/ui/generic-associated-types/missing-item-sugg.rs
Normal file
11
tests/ui/generic-associated-types/missing-item-sugg.rs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
// aux-build:missing-item-sugg.rs
|
||||||
|
|
||||||
|
extern crate missing_item_sugg;
|
||||||
|
|
||||||
|
struct Local;
|
||||||
|
impl missing_item_sugg::Foo for Local {
|
||||||
|
//~^ ERROR not all trait items implemented, missing: `Gat`
|
||||||
|
}
|
||||||
|
//~^ HELP implement the missing item: `type Gat<T> = /* Type */ where T: std::fmt::Display;`
|
||||||
|
|
||||||
|
fn main() {}
|
11
tests/ui/generic-associated-types/missing-item-sugg.stderr
Normal file
11
tests/ui/generic-associated-types/missing-item-sugg.stderr
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
error[E0046]: not all trait items implemented, missing: `Gat`
|
||||||
|
--> $DIR/missing-item-sugg.rs:6:1
|
||||||
|
|
|
||||||
|
LL | impl missing_item_sugg::Foo for Local {
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Gat` in implementation
|
||||||
|
|
|
||||||
|
= help: implement the missing item: `type Gat<T> = /* Type */ where T: std::fmt::Display;`
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0046`.
|
|
@ -1,7 +1,7 @@
|
||||||
error[E0046]: not all trait items implemented, missing: `Type`, `bar`, `baz`, `A`
|
error[E0046]: not all trait items implemented, missing: `Type`, `bar`, `baz`, `A`
|
||||||
--> $DIR/missing-assoc-fn-applicable-suggestions.rs:7:1
|
--> $DIR/missing-assoc-fn-applicable-suggestions.rs:7:1
|
||||||
|
|
|
|
||||||
LL | impl TraitA<()> for S {
|
LL | impl TraitA<()> for S {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^ missing `Type`, `bar`, `baz`, `A` in implementation
|
| ^^^^^^^^^^^^^^^^^^^^^ missing `Type`, `bar`, `baz`, `A` in implementation
|
||||||
|
|
|
|
||||||
= help: implement the missing item: `type Type = /* Type */;`
|
= help: implement the missing item: `type Type = /* Type */;`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue