Skip to content

Commit 9c3bf4d

Browse files
committed
Consider patterns in fn params in an Elided(Infer) lifetime rib.
1 parent 4891d57 commit 9c3bf4d

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

compiler/rustc_resolve/src/late.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -1853,9 +1853,11 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
18531853
let mut bindings = smallvec![(PatBoundCtx::Product, Default::default())];
18541854
for (index, (pat, ty)) in inputs.enumerate() {
18551855
debug!(?pat, ?ty);
1856-
if let Some(pat) = pat {
1857-
self.resolve_pattern(pat, PatternSource::FnParam, &mut bindings);
1858-
}
1856+
self.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| {
1857+
if let Some(pat) = pat {
1858+
this.resolve_pattern(pat, PatternSource::FnParam, &mut bindings);
1859+
}
1860+
});
18591861
self.visit_ty(ty);
18601862

18611863
if let Some(ref candidates) = self.lifetime_elision_candidates {
@@ -2827,10 +2829,13 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
28272829

28282830
fn resolve_params(&mut self, params: &'ast [Param]) {
28292831
let mut bindings = smallvec![(PatBoundCtx::Product, Default::default())];
2830-
for Param { pat, ty, .. } in params {
2831-
self.resolve_pattern(pat, PatternSource::FnParam, &mut bindings);
2832+
self.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| {
2833+
for Param { pat, .. } in params {
2834+
this.resolve_pattern(pat, PatternSource::FnParam, &mut bindings);
2835+
}
2836+
});
2837+
for Param { ty, .. } in params {
28322838
self.visit_ty(ty);
2833-
debug!("(resolving function / closure) recorded parameter");
28342839
}
28352840
}
28362841

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)