about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-01-06 18:15:56 +0000
committerbors <bors@rust-lang.org>2023-01-06 18:15:56 +0000
commit0fb8b72ce49997d60a631e921d2cf5be9ca229e6 (patch)
treec56824419fa9e82b7a13f357dfd58ce7765248ba /compiler/rustc_hir_analysis/src
parentafe8c4537c9009a251a31e8f022b7795fc305d4f (diff)
parentde1859fc324a323dfd0033d666c64f82ff2f130f (diff)
downloadrust-0fb8b72ce49997d60a631e921d2cf5be9ca229e6.tar.gz
rust-0fb8b72ce49997d60a631e921d2cf5be9ca229e6.zip
Auto merge of #106501 - cjgillot:resolved-elided-apit, r=compiler-errors
Correct detection of elided lifetimes in impl-trait.

Fixes https://github.com/rust-lang/rust/issues/106338

r? `@compiler-errors`
cc `@pnkfelix`
Diffstat (limited to 'compiler/rustc_hir_analysis/src')
-rw-r--r--compiler/rustc_hir_analysis/src/collect/lifetimes.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/rustc_hir_analysis/src/collect/lifetimes.rs b/compiler/rustc_hir_analysis/src/collect/lifetimes.rs
index 0a1188c16a8..35f10dc8737 100644
--- a/compiler/rustc_hir_analysis/src/collect/lifetimes.rs
+++ b/compiler/rustc_hir_analysis/src/collect/lifetimes.rs
@@ -1195,8 +1195,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
                     // Fresh lifetimes in APIT used to be allowed in async fns and forbidden in
                     // regular fns.
                     if let Some(hir::PredicateOrigin::ImplTrait) = where_bound_origin
-                        && let hir::LifetimeName::Param(_) = lifetime_ref.res
-                        && lifetime_ref.is_anonymous()
+                        && let hir::LifetimeName::Param(param_id) = lifetime_ref.res
+                        && let Some(generics) = self.tcx.hir().get_generics(self.tcx.local_parent(param_id))
+                        && let Some(param) = generics.params.iter().find(|p| p.def_id == param_id)
+                        && param.is_elided_lifetime()
                         && let hir::IsAsync::NotAsync = self.tcx.asyncness(lifetime_ref.hir_id.owner.def_id)
                         && !self.tcx.features().anonymous_lifetime_in_impl_trait
                     {