@@ -1145,29 +1145,24 @@ fn detect_same_item_push<'tcx>(
11451145 let vec_str = snippet_with_macro_callsite ( cx, vec. span , "" ) ;
11461146 let item_str = snippet_with_macro_callsite ( cx, pushed_item. span , "" ) ;
11471147 if let ExprKind :: Path ( ref qpath) = pushed_item. kind {
1148- if let Res :: Local ( hir_id) = qpath_res ( cx, qpath, pushed_item. hir_id ) {
1148+ if_chain ! {
1149+ if let Res :: Local ( hir_id) = qpath_res( cx, qpath, pushed_item. hir_id) ;
11491150 let node = cx. tcx. hir( ) . get( hir_id) ;
1150- if_chain ! {
1151- if let Node :: Binding ( pat) = node;
1152- if let PatKind :: Binding ( bind_ann, ..) = pat. kind;
1153- then {
1154- match bind_ann {
1155- BindingAnnotation :: RefMut | BindingAnnotation :: Mutable => { } ,
1156- _ => {
1157- span_lint_and_help(
1158- cx,
1159- SAME_ITEM_PUSH ,
1160- vec. span,
1161- "it looks like the same item is being pushed into this Vec" ,
1162- None ,
1163- & format!(
1164- "try using vec![{};SIZE] or {}.resize(NEW_SIZE, {})" ,
1165- item_str, vec_str, item_str
1166- ) ,
1167- )
1168- }
1169- }
1170- }
1151+ if let Node :: Binding ( pat) = node;
1152+ if let PatKind :: Binding ( bind_ann, ..) = pat. kind;
1153+ if !matches!( bind_ann, BindingAnnotation :: RefMut | BindingAnnotation :: Mutable ) ;
1154+ then {
1155+ span_lint_and_help(
1156+ cx,
1157+ SAME_ITEM_PUSH ,
1158+ vec. span,
1159+ "it looks like the same item is being pushed into this Vec" ,
1160+ None ,
1161+ & format!(
1162+ "try using vec![{};SIZE] or {}.resize(NEW_SIZE, {})" ,
1163+ item_str, vec_str, item_str
1164+ ) ,
1165+ )
11711166 }
11721167 }
11731168 } else if mutated_variables ( pushed_item, cx) . map_or ( false , |mutvars| mutvars. is_empty ( ) ) {
0 commit comments