Consider patterns in fn params in an Elided(Infer) lifetime rib.
This commit is contained in:
@@ -1853,9 +1853,11 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
|||||||
let mut bindings = smallvec![(PatBoundCtx::Product, Default::default())];
|
let mut bindings = smallvec![(PatBoundCtx::Product, Default::default())];
|
||||||
for (index, (pat, ty)) in inputs.enumerate() {
|
for (index, (pat, ty)) in inputs.enumerate() {
|
||||||
debug!(?pat, ?ty);
|
debug!(?pat, ?ty);
|
||||||
|
self.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| {
|
||||||
if let Some(pat) = pat {
|
if let Some(pat) = pat {
|
||||||
self.resolve_pattern(pat, PatternSource::FnParam, &mut bindings);
|
this.resolve_pattern(pat, PatternSource::FnParam, &mut bindings);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
self.visit_ty(ty);
|
self.visit_ty(ty);
|
||||||
|
|
||||||
if let Some(ref candidates) = self.lifetime_elision_candidates {
|
if let Some(ref candidates) = self.lifetime_elision_candidates {
|
||||||
@@ -2827,10 +2829,13 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
|||||||
|
|
||||||
fn resolve_params(&mut self, params: &'ast [Param]) {
|
fn resolve_params(&mut self, params: &'ast [Param]) {
|
||||||
let mut bindings = smallvec![(PatBoundCtx::Product, Default::default())];
|
let mut bindings = smallvec![(PatBoundCtx::Product, Default::default())];
|
||||||
for Param { pat, ty, .. } in params {
|
self.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| {
|
||||||
self.resolve_pattern(pat, PatternSource::FnParam, &mut bindings);
|
for Param { pat, .. } in params {
|
||||||
|
this.resolve_pattern(pat, PatternSource::FnParam, &mut bindings);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
for Param { ty, .. } in params {
|
||||||
self.visit_ty(ty);
|
self.visit_ty(ty);
|
||||||
debug!("(resolving function / closure) recorded parameter");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
11
src/test/ui/lifetimes/elided-lifetime-in-param-pat.rs
Normal file
11
src/test/ui/lifetimes/elided-lifetime-in-param-pat.rs
Normal 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 });
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user