@@ -1482,25 +1482,28 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14821482 ident_name : Symbol ,
14831483 }
14841484
1485+ // FIXME: This really should be taking scoping, etc into account.
14851486 impl < ' v > Visitor < ' v > for LetVisitor < ' v > {
14861487 fn visit_stmt ( & mut self , ex : & ' v hir:: Stmt < ' v > ) {
1487- if let hir:: StmtKind :: Local ( hir:: Local { pat, init, .. } ) = & ex. kind {
1488- if let Binding ( _, _, ident, ..) = pat. kind &&
1489- ident. name == self . ident_name {
1490- self . result = * init;
1491- }
1488+ if let hir:: StmtKind :: Local ( hir:: Local { pat, init, .. } ) = & ex. kind
1489+ && let Binding ( _, _, ident, ..) = pat. kind
1490+ && ident. name == self . ident_name
1491+ {
1492+ self . result = * init;
1493+ } else {
1494+ hir:: intravisit:: walk_stmt ( self , ex) ;
14921495 }
1493- hir:: intravisit:: walk_stmt ( self , ex) ;
14941496 }
14951497 }
14961498
14971499 let mut visitor = LetVisitor { result : None , ident_name : seg1. ident . name } ;
14981500 visitor. visit_body ( & body) ;
14991501
15001502 let parent = self . tcx . hir ( ) . get_parent_node ( seg1. hir_id ) ;
1501- if let Some ( Node :: Expr ( call_expr) ) = self . tcx . hir ( ) . find ( parent) &&
1502- let Some ( expr) = visitor. result {
1503- let self_ty = self . node_ty ( expr. hir_id ) ;
1503+ if let Some ( Node :: Expr ( call_expr) ) = self . tcx . hir ( ) . find ( parent)
1504+ && let Some ( expr) = visitor. result
1505+ && let Some ( self_ty) = self . node_ty_opt ( expr. hir_id )
1506+ {
15041507 let probe = self . lookup_probe (
15051508 seg2. ident ,
15061509 self_ty,
@@ -1513,7 +1516,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15131516 sm. span_extend_while ( seg1. ident . span . shrink_to_hi ( ) , |c| c == ':' ) . unwrap ( ) ,
15141517 "you may have meant to call an instance method" ,
15151518 "." . to_string ( ) ,
1516- Applicability :: MaybeIncorrect
1519+ Applicability :: MaybeIncorrect ,
15171520 ) ;
15181521 }
15191522 }
0 commit comments