Skip to content

Commit ed11812

Browse files
committed
extend E0623 for fns
1 parent 2f50c33 commit ed11812

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/librustc/infer/error_reporting/anon_anon_conflict.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
192192
hir_map: &self.tcx.hir,
193193
bound_region: *br,
194194
found_type: None,
195+
depth: 0,
195196
};
196197
nested_visitor.visit_ty(arg);
197198
nested_visitor.found_type
@@ -214,6 +215,7 @@ struct FindNestedTypeVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
214215
// The type where the anonymous lifetime appears
215216
// for e.g. Vec<`&u8`> and <`&u8`>
216217
found_type: Option<&'gcx hir::Ty>,
218+
depth: u32,
217219
}
218220

219221
impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
@@ -263,11 +265,35 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
263265
self.found_type = Some(arg);
264266
}
265267
}
268+
269+
hir::TyBareFn(ref fndecl) => {
270+
fndecl.lifetimes.iter().filter_map(|lf| {
271+
match self.infcx.tcx.named_region_map.defs.get(&lf.lifetime.id) {
272+
273+
Some(&rl::Region::LateBoundAnon(debuijn_index, anon_index)) => {
274+
if debuijn_index.depth == self.depth && anon_index == br_index {
275+
self.found_type = Some(arg);
276+
return; // we can stop visiting now
277+
}else{}
278+
}
279+
Some(&rl::Region::Static) |
280+
Some(&rl::Region::EarlyBound(_, _)) |
281+
Some(&rl::Region::LateBound(_, _)) |
282+
Some(&rl::Region::Free(_, _)) |
283+
None => {
284+
debug!("no arg found");
285+
}
286+
}
287+
288+
}).next();}
289+
266290
_ => {}
267291
}
268292
// walk the embedded contents: e.g., if we are visiting `Vec<&Foo>`,
269293
// go on to visit `&Foo`
294+
self.depth += 1;
270295
intravisit::walk_ty(self, arg);
296+
self.depth += 1;
271297
}
272298
}
273299

0 commit comments

Comments
 (0)