Skip to content

Commit

Permalink
Auto merge of rust-lang#5400 - flip1995:rustup, r=Manishearth
Browse files Browse the repository at this point in the history
Rustups

r? @Manishearth

changelog: none
  • Loading branch information
bors committed Apr 1, 2020
2 parents c211cea + fcc56fc commit 326b220
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ fn get_indexed_assignments<'a, 'tcx>(
.chain(expr.as_ref().into_iter().map(|e| Some(get_assignment(cx, &*e, var))))
.filter_map(|op| op)
.collect::<Option<Vec<_>>>()
.unwrap_or_else(|| vec![])
.unwrap_or_default()
} else {
get_assignment(cx, body, var).into_iter().collect()
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/redundant_clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeStorageLive {
_block: mir::BasicBlock,
_func: &mir::Operand<'tcx>,
_args: &[mir::Operand<'tcx>],
_return_place: &mir::Place<'tcx>,
_return_place: mir::Place<'tcx>,
) {
// Nothing to do when a call returns successfully
}
Expand Down
3 changes: 3 additions & 0 deletions clippy_lints/src/utils/higher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ pub fn vec_macro<'e>(cx: &LateContext<'_, '_>, expr: &'e hir::Expr<'_>) -> Optio

None
}
else if match_def_path(cx, fun_def_id, &paths::VEC_NEW) && args.is_empty() {
Some(VecArgs::Vec(&[]))
}
else {
None
};
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/utils/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,6 @@ pub const VEC_AS_MUT_SLICE: [&str; 4] = ["alloc", "vec", "Vec", "as_mut_slice"];
pub const VEC_AS_SLICE: [&str; 4] = ["alloc", "vec", "Vec", "as_slice"];
pub const VEC_DEQUE: [&str; 4] = ["alloc", "collections", "vec_deque", "VecDeque"];
pub const VEC_FROM_ELEM: [&str; 3] = ["alloc", "vec", "from_elem"];
pub const VEC_NEW: [&str; 4] = ["alloc", "vec", "Vec", "new"];
pub const WEAK_ARC: [&str; 3] = ["alloc", "sync", "Weak"];
pub const WEAK_RC: [&str; 3] = ["alloc", "rc", "Weak"];
4 changes: 1 addition & 3 deletions tests/ui/or_fun_call.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ fn or_fun_call() {
with_default_type.unwrap_or_default();

let with_vec = Some(vec![1]);
with_vec.unwrap_or_else(|| vec![]);

// FIXME #944: ~|SUGGESTION with_vec.unwrap_or_else(|| vec![]);
with_vec.unwrap_or_default();

let without_default = Some(Foo);
without_default.unwrap_or_else(Foo::new);
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/or_fun_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ fn or_fun_call() {
let with_vec = Some(vec![1]);
with_vec.unwrap_or(vec![]);

// FIXME #944: ~|SUGGESTION with_vec.unwrap_or_else(|| vec![]);

let without_default = Some(Foo);
without_default.unwrap_or(Foo::new());

Expand Down
16 changes: 8 additions & 8 deletions tests/ui/or_fun_call.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,38 @@ error: use of `unwrap_or` followed by a call to `default`
LL | with_default_type.unwrap_or(u64::default());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_type.unwrap_or_default()`

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

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

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

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

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

error: use of `or` followed by a function call
--> $DIR/or_fun_call.rs:95:35
--> $DIR/or_fun_call.rs:93:35
|
LL | let _ = Some("a".to_string()).or(Some("b".to_string()));
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_else(|| Some("b".to_string()))`
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/unit_arg.fixed
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// run-rustfix
#![warn(clippy::unit_arg)]
#![allow(clippy::no_effect, unused_must_use)]
#![allow(unused_braces, clippy::no_effect, unused_must_use)]

use std::fmt::Debug;

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/unit_arg.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// run-rustfix
#![warn(clippy::unit_arg)]
#![allow(clippy::no_effect, unused_must_use)]
#![allow(unused_braces, clippy::no_effect, unused_must_use)]

use std::fmt::Debug;

Expand Down

0 comments on commit 326b220

Please sign in to comment.