Skip to content

Commit ce2461e

Browse files
committed
running cargo dev fmt
1 parent a6bc3af commit ce2461e

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

clippy_lints/src/arc_new_in_vec_from_slice.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
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};
14
use rustc_hir::*;
25
use rustc_lint::{LateContext, LateLintPass};
36
use 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};
77
use rustc_span::sym;
88

99
declare_clippy_lint! {
@@ -34,7 +34,9 @@ declare_lint_pass!(ArcNewInVecFromSlice => [ARC_NEW_IN_VEC_FROM_SLICE]);
3434
impl 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;

tests/ui/arc_new_in_vec_from_slice/complex_case.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
use std::sync::Mutex;
33

44
fn 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
}
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
#![warn(clippy::arc_new_in_vec_from_slice)]
2-
use std::sync::{Mutex, Arc};
2+
use std::sync::{Arc, Mutex};
33

44
fn 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
}

0 commit comments

Comments
 (0)