Skip to content

Commit 326b220

Browse files
committed
Auto merge of #5400 - flip1995:rustup, r=Manishearth
Rustups r? @Manishearth changelog: none
2 parents c211cea + fcc56fc commit 326b220

File tree

9 files changed

+17
-17
lines changed

9 files changed

+17
-17
lines changed

clippy_lints/src/loops.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ fn get_indexed_assignments<'a, 'tcx>(
922922
.chain(expr.as_ref().into_iter().map(|e| Some(get_assignment(cx, &*e, var))))
923923
.filter_map(|op| op)
924924
.collect::<Option<Vec<_>>>()
925-
.unwrap_or_else(|| vec![])
925+
.unwrap_or_default()
926926
} else {
927927
get_assignment(cx, body, var).into_iter().collect()
928928
}

clippy_lints/src/redundant_clone.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeStorageLive {
437437
_block: mir::BasicBlock,
438438
_func: &mir::Operand<'tcx>,
439439
_args: &[mir::Operand<'tcx>],
440-
_return_place: &mir::Place<'tcx>,
440+
_return_place: mir::Place<'tcx>,
441441
) {
442442
// Nothing to do when a call returns successfully
443443
}

clippy_lints/src/utils/higher.rs

+3
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ pub fn vec_macro<'e>(cx: &LateContext<'_, '_>, expr: &'e hir::Expr<'_>) -> Optio
280280

281281
None
282282
}
283+
else if match_def_path(cx, fun_def_id, &paths::VEC_NEW) && args.is_empty() {
284+
Some(VecArgs::Vec(&[]))
285+
}
283286
else {
284287
None
285288
};

clippy_lints/src/utils/paths.rs

+1
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,6 @@ pub const VEC_AS_MUT_SLICE: [&str; 4] = ["alloc", "vec", "Vec", "as_mut_slice"];
131131
pub const VEC_AS_SLICE: [&str; 4] = ["alloc", "vec", "Vec", "as_slice"];
132132
pub const VEC_DEQUE: [&str; 4] = ["alloc", "collections", "vec_deque", "VecDeque"];
133133
pub const VEC_FROM_ELEM: [&str; 3] = ["alloc", "vec", "from_elem"];
134+
pub const VEC_NEW: [&str; 4] = ["alloc", "vec", "Vec", "new"];
134135
pub const WEAK_ARC: [&str; 3] = ["alloc", "sync", "Weak"];
135136
pub const WEAK_RC: [&str; 3] = ["alloc", "rc", "Weak"];

tests/ui/or_fun_call.fixed

+1-3
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ fn or_fun_call() {
5353
with_default_type.unwrap_or_default();
5454

5555
let with_vec = Some(vec![1]);
56-
with_vec.unwrap_or_else(|| vec![]);
57-
58-
// FIXME #944: ~|SUGGESTION with_vec.unwrap_or_else(|| vec![]);
56+
with_vec.unwrap_or_default();
5957

6058
let without_default = Some(Foo);
6159
without_default.unwrap_or_else(Foo::new);

tests/ui/or_fun_call.rs

-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ fn or_fun_call() {
5555
let with_vec = Some(vec![1]);
5656
with_vec.unwrap_or(vec![]);
5757

58-
// FIXME #944: ~|SUGGESTION with_vec.unwrap_or_else(|| vec![]);
59-
6058
let without_default = Some(Foo);
6159
without_default.unwrap_or(Foo::new());
6260

tests/ui/or_fun_call.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -42,38 +42,38 @@ error: use of `unwrap_or` followed by a call to `default`
4242
LL | with_default_type.unwrap_or(u64::default());
4343
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_type.unwrap_or_default()`
4444

45-
error: use of `unwrap_or` followed by a function call
46-
--> $DIR/or_fun_call.rs:56:14
45+
error: use of `unwrap_or` followed by a call to `new`
46+
--> $DIR/or_fun_call.rs:56:5
4747
|
4848
LL | with_vec.unwrap_or(vec![]);
49-
| ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| vec![])`
49+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_vec.unwrap_or_default()`
5050

5151
error: use of `unwrap_or` followed by a function call
52-
--> $DIR/or_fun_call.rs:61:21
52+
--> $DIR/or_fun_call.rs:59:21
5353
|
5454
LL | without_default.unwrap_or(Foo::new());
5555
| ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(Foo::new)`
5656

5757
error: use of `or_insert` followed by a function call
58-
--> $DIR/or_fun_call.rs:64:19
58+
--> $DIR/or_fun_call.rs:62:19
5959
|
6060
LL | map.entry(42).or_insert(String::new());
6161
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
6262

6363
error: use of `or_insert` followed by a function call
64-
--> $DIR/or_fun_call.rs:67:21
64+
--> $DIR/or_fun_call.rs:65:21
6565
|
6666
LL | btree.entry(42).or_insert(String::new());
6767
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
6868

6969
error: use of `unwrap_or` followed by a function call
70-
--> $DIR/or_fun_call.rs:70:21
70+
--> $DIR/or_fun_call.rs:68:21
7171
|
7272
LL | let _ = stringy.unwrap_or("".to_owned());
7373
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "".to_owned())`
7474

7575
error: use of `or` followed by a function call
76-
--> $DIR/or_fun_call.rs:95:35
76+
--> $DIR/or_fun_call.rs:93:35
7777
|
7878
LL | let _ = Some("a".to_string()).or(Some("b".to_string()));
7979
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_else(|| Some("b".to_string()))`

tests/ui/unit_arg.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-rustfix
22
#![warn(clippy::unit_arg)]
3-
#![allow(clippy::no_effect, unused_must_use)]
3+
#![allow(unused_braces, clippy::no_effect, unused_must_use)]
44

55
use std::fmt::Debug;
66

tests/ui/unit_arg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-rustfix
22
#![warn(clippy::unit_arg)]
3-
#![allow(clippy::no_effect, unused_must_use)]
3+
#![allow(unused_braces, clippy::no_effect, unused_must_use)]
44

55
use std::fmt::Debug;
66

0 commit comments

Comments
 (0)