diff --git a/compiler/rustc_hir_analysis/src/check/mod.rs b/compiler/rustc_hir_analysis/src/check/mod.rs index 4247869ce7603..1dfe053b21530 100644 --- a/compiler/rustc_hir_analysis/src/check/mod.rs +++ b/compiler/rustc_hir_analysis/src/check/mod.rs @@ -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, diff --git a/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed b/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed index 16c4d15ddcd60..d9f775a6c8464 100644 --- a/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed +++ b/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed @@ -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!() } } diff --git a/tests/ui/impl-trait/in-trait/suggest-missing-item.rs b/tests/ui/impl-trait/in-trait/suggest-missing-item.rs index f218e6cb581e3..26979b5149b06 100644 --- a/tests/ui/impl-trait/in-trait/suggest-missing-item.rs +++ b/tests/ui/impl-trait/in-trait/suggest-missing-item.rs @@ -9,6 +9,8 @@ trait Trait { async fn bar() -> i32; fn test(&self) -> impl Sized + '_; + + async fn baz(&self) -> &i32; } struct S; diff --git a/tests/ui/impl-trait/in-trait/suggest-missing-item.stderr b/tests/ui/impl-trait/in-trait/suggest-missing-item.stderr index d96641fe16335..44f98896eb384 100644 --- a/tests/ui/impl-trait/in-trait/suggest-missing-item.stderr +++ b/tests/ui/impl-trait/in-trait/suggest-missing-item.stderr @@ -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