@@ -27,7 +27,7 @@ fn check_needless_collect_direct_usage<'tcx>(expr: &'tcx Expr<'_>, cx: &LateCont
27
27
if chain_method. ident. name == sym!( collect) && is_trait_method( cx, & args[ 0 ] , sym:: Iterator ) ;
28
28
if let Some ( generic_args) = chain_method. args;
29
29
if let Some ( GenericArg :: Type ( ref ty) ) = generic_args. args. get( 0 ) ;
30
- let ty = cx. typeck_results( ) . node_type ( ty. hir_id) ;
30
+ if let Some ( ty ) = cx. typeck_results( ) . node_type_opt ( ty. hir_id) ;
31
31
if is_type_diagnostic_item( cx, ty, sym:: vec_type)
32
32
|| is_type_diagnostic_item( cx, ty, sym:: vecdeque_type)
33
33
|| match_type( cx, ty, & paths:: BTREEMAP )
@@ -82,7 +82,7 @@ fn check_needless_collect_indirect_usage<'tcx>(expr: &'tcx Expr<'_>, cx: &LateCo
82
82
if let ExprKind :: MethodCall ( method_name, collect_span, & [ ref iter_source] , ..) = init_expr. kind;
83
83
if method_name. ident. name == sym!( collect) && is_trait_method( cx, init_expr, sym:: Iterator ) ;
84
84
if let Some ( hir_id) = get_hir_id( * ty, method_name. args) ;
85
- if let ty = cx. typeck_results( ) . node_type ( hir_id) ;
85
+ if let Some ( ty ) = cx. typeck_results( ) . node_type_opt ( hir_id) ;
86
86
if is_type_diagnostic_item( cx, ty, sym:: vec_type) ||
87
87
is_type_diagnostic_item( cx, ty, sym:: vecdeque_type) ||
88
88
is_type_diagnostic_item( cx, ty, sym:: BinaryHeap ) ||
0 commit comments