Rollup merge of #103216 - cjgillot:issue-103210, r=jackh726

Consider patterns in fn params in an `Elided(Infer)` lifetime rib.

Fixes https://github.com/rust-lang/rust/issues/103210
This commit is contained in:
Dylan DPC 2022-10-19 14:05:54 +05:30 committed by GitHub
commit 32159e3fa4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 6 deletions

View File

@ -1862,9 +1862,11 @@ fn resolve_fn_params(
let mut bindings = smallvec![(PatBoundCtx::Product, Default::default())];
for (index, (pat, ty)) in inputs.enumerate() {
debug!(?pat, ?ty);
if let Some(pat) = pat {
self.resolve_pattern(pat, PatternSource::FnParam, &mut bindings);
}
self.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| {
if let Some(pat) = pat {
this.resolve_pattern(pat, PatternSource::FnParam, &mut bindings);
}
});
self.visit_ty(ty);
if let Some(ref candidates) = self.lifetime_elision_candidates {
@ -2834,10 +2836,13 @@ fn check_trait_item<F>(
fn resolve_params(&mut self, params: &'ast [Param]) {
let mut bindings = smallvec![(PatBoundCtx::Product, Default::default())];
for Param { pat, ty, .. } in params {
self.resolve_pattern(pat, PatternSource::FnParam, &mut bindings);
self.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| {
for Param { pat, .. } in params {
this.resolve_pattern(pat, PatternSource::FnParam, &mut bindings);
}
});
for Param { ty, .. } in params {
self.visit_ty(ty);
debug!("(resolving function / closure) recorded parameter");
}
}

View File

@ -0,0 +1,11 @@
// check-pass
struct S<T> {
_t: T,
}
fn f(S::<&i8> { .. }: S<&i8>) {}
fn main() {
f(S { _t: &42_i8 });
}