Rollup merge of #112868 - compiler-errors:liberate-afit-sugg, r=WaffleLapkin
Liberate bound vars properly when suggesting missing async-fn-in-trait Fixes #112848
This commit is contained in:
commit
5ed75a9628
@ -470,19 +470,16 @@ fn suggestion_signature<'tcx>(
|
||||
);
|
||||
|
||||
match assoc.kind {
|
||||
ty::AssocKind::Fn => {
|
||||
// We skip the binder here because the binder would deanonymize all
|
||||
// late-bound regions, and we don't want method signatures to show up
|
||||
// `as for<'r> fn(&'r MyType)`. Pretty-printing handles late-bound
|
||||
// regions just fine, showing `fn(&MyType)`.
|
||||
fn_sig_suggestion(
|
||||
tcx,
|
||||
tcx.fn_sig(assoc.def_id).subst(tcx, substs).skip_binder(),
|
||||
assoc.ident(tcx),
|
||||
tcx.predicates_of(assoc.def_id).instantiate_own(tcx, substs),
|
||||
assoc,
|
||||
)
|
||||
}
|
||||
ty::AssocKind::Fn => fn_sig_suggestion(
|
||||
tcx,
|
||||
tcx.liberate_late_bound_regions(
|
||||
assoc.def_id,
|
||||
tcx.fn_sig(assoc.def_id).subst(tcx, substs),
|
||||
),
|
||||
assoc.ident(tcx),
|
||||
tcx.predicates_of(assoc.def_id).instantiate_own(tcx, substs),
|
||||
assoc,
|
||||
),
|
||||
ty::AssocKind::Type => {
|
||||
let (generics, where_clauses) = bounds_from_generic_predicates(
|
||||
tcx,
|
||||
|
@ -9,11 +9,14 @@ trait Trait {
|
||||
async fn bar() -> i32;
|
||||
|
||||
fn test(&self) -> impl Sized + '_;
|
||||
|
||||
async fn baz(&self) -> &i32;
|
||||
}
|
||||
|
||||
struct S;
|
||||
|
||||
impl Trait for S {fn test(&self) -> impl Sized + '_ { todo!() }
|
||||
impl Trait for S {async fn baz(&self) -> &i32 { todo!() }
|
||||
fn test(&self) -> impl Sized + '_ { todo!() }
|
||||
async fn bar() -> i32 { todo!() }
|
||||
async fn foo() { todo!() }
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ trait Trait {
|
||||
async fn bar() -> i32;
|
||||
|
||||
fn test(&self) -> impl Sized + '_;
|
||||
|
||||
async fn baz(&self) -> &i32;
|
||||
}
|
||||
|
||||
struct S;
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0046]: not all trait items implemented, missing: `foo`, `bar`, `test`
|
||||
--> $DIR/suggest-missing-item.rs:16:1
|
||||
error[E0046]: not all trait items implemented, missing: `foo`, `bar`, `test`, `baz`
|
||||
--> $DIR/suggest-missing-item.rs:18:1
|
||||
|
|
||||
LL | async fn foo();
|
||||
| --------------- `foo` from trait
|
||||
@ -9,9 +9,12 @@ LL | async fn bar() -> i32;
|
||||
LL |
|
||||
LL | fn test(&self) -> impl Sized + '_;
|
||||
| ---------------------------------- `test` from trait
|
||||
LL |
|
||||
LL | async fn baz(&self) -> &i32;
|
||||
| ---------------------------- `baz` from trait
|
||||
...
|
||||
LL | impl Trait for S {}
|
||||
| ^^^^^^^^^^^^^^^^ missing `foo`, `bar`, `test` in implementation
|
||||
| ^^^^^^^^^^^^^^^^ missing `foo`, `bar`, `test`, `baz` in implementation
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user