File tree Expand file tree Collapse file tree 3 files changed +23
-15
lines changed
tests/ui/arc_new_in_vec_from_slice Expand file tree Collapse file tree 3 files changed +23
-15
lines changed Original file line number Diff line number Diff line change 1+ use clippy_utils:: diagnostics:: span_lint_and_help;
2+ use clippy_utils:: macros:: { root_macro_call_first_node, MacroCall } ;
3+ use clippy_utils:: { last_path_segment, match_def_path, paths} ;
14use rustc_hir:: * ;
25use rustc_lint:: { LateContext , LateLintPass } ;
36use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
4- use clippy_utils:: diagnostics:: span_lint_and_help;
5- use clippy_utils:: macros:: { MacroCall , root_macro_call_first_node} ;
6- use clippy_utils:: { last_path_segment, match_def_path, paths} ;
77use rustc_span:: sym;
88
99declare_clippy_lint ! {
@@ -34,7 +34,9 @@ declare_lint_pass!(ArcNewInVecFromSlice => [ARC_NEW_IN_VEC_FROM_SLICE]);
3434impl LateLintPass < ' _ > for ArcNewInVecFromSlice {
3535 fn check_expr ( & mut self , cx : & LateContext < ' _ > , expr : & Expr < ' _ > ) {
3636 let Some ( macro_call) = root_macro_call_first_node ( cx, expr) else { return ; } ;
37- if !macro_is_vec ( cx, & macro_call) { return ; }
37+ if !macro_is_vec ( cx, & macro_call) {
38+ return ;
39+ }
3840
3941 if_chain ! {
4042 if let ExprKind :: Call ( func, args) = expr. peel_drop_temps( ) . kind;
Original file line number Diff line number Diff line change 22use std:: sync:: Mutex ;
33
44fn main ( ) {
5- let v = vec ! [ std:: sync:: Arc :: new( Mutex :: new( {
6- let x = 1 ;
7- dbg!( x) ;
8- x
9- } ) ) ; 2 ] ;
5+ let v = vec ! [
6+ std:: sync:: Arc :: new( Mutex :: new( {
7+ let x = 1 ;
8+ dbg!( x) ;
9+ x
10+ } ) ) ;
11+ 2
12+ ] ;
1013}
Original file line number Diff line number Diff line change 11#![ warn( clippy:: arc_new_in_vec_from_slice) ]
2- use std:: sync:: { Mutex , Arc } ;
2+ use std:: sync:: { Arc , Mutex } ;
33
44fn main ( ) {
55 let v = vec ! [ String :: new( ) ; 2 ] ;
66 let v1 = vec ! [ 1 ; 2 ] ;
7- let v2 = vec ! [ Box :: new( std:: sync:: Arc :: new( {
8- let y = 3 ;
9- dbg!( y) ;
10- y
11- } ) ) ; 2 ] ;
7+ let v2 = vec ! [
8+ Box :: new( std:: sync:: Arc :: new( {
9+ let y = 3 ;
10+ dbg!( y) ;
11+ y
12+ } ) ) ;
13+ 2
14+ ] ;
1215}
You can’t perform that action at this time.
0 commit comments