@@ -356,6 +356,7 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> {
356
356
let kind = match self . impl_trait_context {
357
357
ImplTraitContext :: Universal => DefKind :: TyParam ,
358
358
ImplTraitContext :: Existential => DefKind :: OpaqueTy ,
359
+ ImplTraitContext :: InBinding => return visit:: walk_ty ( self , ty) ,
359
360
} ;
360
361
let id = self . create_def ( * id, name, kind, ty. span ) ;
361
362
match self . impl_trait_context {
@@ -365,6 +366,7 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> {
365
366
ImplTraitContext :: Existential => {
366
367
self . with_parent ( id, |this| visit:: walk_ty ( this, ty) )
367
368
}
369
+ ImplTraitContext :: InBinding => unreachable ! ( ) ,
368
370
} ;
369
371
}
370
372
_ => visit:: walk_ty ( self , ty) ,
@@ -374,6 +376,13 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> {
374
376
fn visit_stmt ( & mut self , stmt : & ' a Stmt ) {
375
377
match stmt. kind {
376
378
StmtKind :: MacCall ( ..) => self . visit_macro_invoc ( stmt. id ) ,
379
+ // FIXME(impl_trait_in_bindings): We don't really have a good way of
380
+ // introducing the right `ImplTraitContext` here for all the cases we
381
+ // care about, in case we want to introduce ITIB to other positions
382
+ // such as turbofishes (e.g. `foo::<impl Fn()>(|| {})`).
383
+ StmtKind :: Let ( ref local) => self . with_impl_trait ( ImplTraitContext :: InBinding , |this| {
384
+ visit:: walk_local ( this, local)
385
+ } ) ,
377
386
_ => visit:: walk_stmt ( self , stmt) ,
378
387
}
379
388
}
0 commit comments