@@ -643,7 +643,7 @@ impl<'tcx> Visitor<'tcx> for AnnotateUnitFallbackVisitor<'_, 'tcx> {
643643 fn visit_ty ( & mut self , hir_ty : & ' tcx hir:: Ty < ' tcx > ) -> Self :: Result {
644644 // Try to replace `_` with `()`.
645645 if let hir:: TyKind :: Infer = hir_ty. kind
646- && let ty = self . fcx . typeck_results . borrow ( ) . node_type ( hir_ty. hir_id )
646+ && let Some ( ty ) = self . fcx . typeck_results . borrow ( ) . node_type_opt ( hir_ty. hir_id )
647647 && let Some ( vid) = self . fcx . root_vid ( ty)
648648 && self . reachable_vids . contains ( & vid)
649649 {
@@ -680,7 +680,8 @@ impl<'tcx> Visitor<'tcx> for AnnotateUnitFallbackVisitor<'_, 'tcx> {
680680 if let hir:: ExprKind :: Path ( hir:: QPath :: Resolved ( None , path) ) = expr. kind
681681 && let Res :: Def ( DefKind :: AssocFn , def_id) = path. res
682682 && self . fcx . tcx . trait_of_item ( def_id) . is_some ( )
683- && let self_ty = self . fcx . typeck_results . borrow ( ) . node_args ( expr. hir_id ) . type_at ( 0 )
683+ && let Some ( args) = self . fcx . typeck_results . borrow ( ) . node_args_opt ( expr. hir_id )
684+ && let self_ty = args. type_at ( 0 )
684685 && let Some ( vid) = self . fcx . root_vid ( self_ty)
685686 && self . reachable_vids . contains ( & vid)
686687 && let [ .., trait_segment, _method_segment] = path. segments
@@ -701,7 +702,7 @@ impl<'tcx> Visitor<'tcx> for AnnotateUnitFallbackVisitor<'_, 'tcx> {
701702 fn visit_local ( & mut self , local : & ' tcx hir:: LetStmt < ' tcx > ) -> Self :: Result {
702703 // For a local, try suggest annotating the type if it's missing.
703704 if let None = local. ty
704- && let ty = self . fcx . typeck_results . borrow ( ) . node_type ( local. hir_id )
705+ && let Some ( ty ) = self . fcx . typeck_results . borrow ( ) . node_type_opt ( local. hir_id )
705706 && let Some ( vid) = self . fcx . root_vid ( ty)
706707 && self . reachable_vids . contains ( & vid)
707708 {
0 commit comments