Skip to content

Commit 32159e3

Browse files
authored
Rollup merge of #103216 - cjgillot:issue-103210, r=jackh726
Consider patterns in fn params in an `Elided(Infer)` lifetime rib. Fixes #103210
2 parents 02d6135 + 9c3bf4d commit 32159e3

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

Diff for: compiler/rustc_resolve/src/late.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -1862,9 +1862,11 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
18621862
let mut bindings = smallvec![(PatBoundCtx::Product, Default::default())];
18631863
for (index, (pat, ty)) in inputs.enumerate() {
18641864
debug!(?pat, ?ty);
1865-
if let Some(pat) = pat {
1866-
self.resolve_pattern(pat, PatternSource::FnParam, &mut bindings);
1867-
}
1865+
self.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| {
1866+
if let Some(pat) = pat {
1867+
this.resolve_pattern(pat, PatternSource::FnParam, &mut bindings);
1868+
}
1869+
});
18681870
self.visit_ty(ty);
18691871

18701872
if let Some(ref candidates) = self.lifetime_elision_candidates {
@@ -2834,10 +2836,13 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
28342836

28352837
fn resolve_params(&mut self, params: &'ast [Param]) {
28362838
let mut bindings = smallvec![(PatBoundCtx::Product, Default::default())];
2837-
for Param { pat, ty, .. } in params {
2838-
self.resolve_pattern(pat, PatternSource::FnParam, &mut bindings);
2839+
self.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| {
2840+
for Param { pat, .. } in params {
2841+
this.resolve_pattern(pat, PatternSource::FnParam, &mut bindings);
2842+
}
2843+
});
2844+
for Param { ty, .. } in params {
28392845
self.visit_ty(ty);
2840-
debug!("(resolving function / closure) recorded parameter");
28412846
}
28422847
}
28432848

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// check-pass
2+
3+
struct S<T> {
4+
_t: T,
5+
}
6+
7+
fn f(S::<&i8> { .. }: S<&i8>) {}
8+
9+
fn main() {
10+
f(S { _t: &42_i8 });
11+
}

0 commit comments

Comments
 (0)