Skip to content

Commit 6493019

Browse files
committed
fixes after running cargo test and update lints
1 parent ce2461e commit 6493019

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3278,7 +3278,7 @@ Released 2018-09-13
32783278
[`allow_attributes_without_reason`]: https://rust-lang.github.io/rust-clippy/master/index.html#allow_attributes_without_reason
32793279
[`almost_swapped`]: https://rust-lang.github.io/rust-clippy/master/index.html#almost_swapped
32803280
[`approx_constant`]: https://rust-lang.github.io/rust-clippy/master/index.html#approx_constant
3281-
[`arc_in_vec_init`]: https://rust-lang.github.io/rust-clippy/master/index.html#arc_in_vec_init
3281+
[`arc_new_in_vec_from_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#arc_new_in_vec_from_slice
32823282
[`as_conversions`]: https://rust-lang.github.io/rust-clippy/master/index.html#as_conversions
32833283
[`assertions_on_constants`]: https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants
32843284
[`assign_op_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#assign_op_pattern

clippy_lints/src/arc_new_in_vec_from_slice.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::span_lint_and_help;
22
use clippy_utils::macros::{root_macro_call_first_node, MacroCall};
33
use clippy_utils::{last_path_segment, match_def_path, paths};
4-
use rustc_hir::*;
4+
use rustc_hir::{Expr, ExprKind, QPath, TyKind};
55
use rustc_lint::{LateContext, LateLintPass};
66
use rustc_session::{declare_lint_pass, declare_tool_lint};
77
use rustc_span::sym;
@@ -40,7 +40,7 @@ impl LateLintPass<'_> for ArcNewInVecFromSlice {
4040

4141
if_chain! {
4242
if let ExprKind::Call(func, args) = expr.peel_drop_temps().kind;
43-
if let ExprKind::Path(QPath::Resolved(_ty, ref path)) = func.kind;
43+
if let ExprKind::Path(QPath::Resolved(_ty, path)) = func.kind;
4444
if let Some(did) = path.res.opt_def_id();
4545
then {
4646
if !(match_def_path(cx, did, &paths::VEC_FROM_ELEM) && first_arg_is_arc_new(args)) { return; }

tests/ui/arc_new_in_vec_from_slice/complex_case.stderr

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
error: calling `Arc::new` in `vec![elem; len]`
22
--> $DIR/complex_case.rs:5:13
33
|
4-
LL | let v = vec![std::sync::Arc::new(Mutex::new({
4+
LL | let v = vec![
55
| _____________^
6-
LL | | let x = 1;
7-
LL | | dbg!(x);
8-
LL | | x
9-
LL | | })); 2];
10-
| |___________^
6+
LL | | std::sync::Arc::new(Mutex::new({
7+
LL | | let x = 1;
8+
LL | | dbg!(x);
9+
... |
10+
LL | | 2
11+
LL | | ];
12+
| |_____^
1113
|
1214
= note: `-D clippy::arc-new-in-vec-from-slice` implied by `-D warnings`
1315
= help: consider extracting `Arc` initialization to a variable

0 commit comments

Comments
 (0)