manual-unwrap-or / pr remarks
This commit is contained in:
parent
9c9327980b
commit
6d4eeeabcd
8 changed files with 101 additions and 79 deletions
|
|
@ -1,11 +1,13 @@
|
|||
// run-rustfix
|
||||
#![warn(clippy::less_concise_than_option_unwrap_or)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
fn unwrap_or() {
|
||||
// int case
|
||||
Some(1).unwrap_or(42);
|
||||
|
||||
// int case reversed
|
||||
Some(1).unwrap_or(42);
|
||||
|
||||
// richer none expr
|
||||
Some(1).unwrap_or_else(|| 1 + 42);
|
||||
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
// run-rustfix
|
||||
#![warn(clippy::less_concise_than_option_unwrap_or)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
fn unwrap_or() {
|
||||
|
|
@ -9,6 +8,12 @@ fn unwrap_or() {
|
|||
None => 42,
|
||||
};
|
||||
|
||||
// int case reversed
|
||||
match Some(1) {
|
||||
None => 42,
|
||||
Some(i) => i,
|
||||
};
|
||||
|
||||
// richer none expr
|
||||
match Some(1) {
|
||||
Some(i) => i,
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error: this pattern can be more concisely encoded with `Option::unwrap_or`
|
||||
--> $DIR/less_concise_than.rs:7:5
|
||||
error: this pattern reimplements `Option::unwrap_or`
|
||||
--> $DIR/manual_unwrap_or.rs:6:5
|
||||
|
|
||||
LL | / match Some(1) {
|
||||
LL | | Some(i) => i,
|
||||
|
|
@ -7,10 +7,19 @@ LL | | None => 42,
|
|||
LL | | };
|
||||
| |_____^ help: replace with: `Some(1).unwrap_or(42)`
|
||||
|
|
||||
= note: `-D clippy::less-concise-than-option-unwrap-or` implied by `-D warnings`
|
||||
= note: `-D clippy::manual-unwrap-or` implied by `-D warnings`
|
||||
|
||||
error: this pattern can be more concisely encoded with `Option::unwrap_or`
|
||||
--> $DIR/less_concise_than.rs:13:5
|
||||
error: this pattern reimplements `Option::unwrap_or`
|
||||
--> $DIR/manual_unwrap_or.rs:12:5
|
||||
|
|
||||
LL | / match Some(1) {
|
||||
LL | | None => 42,
|
||||
LL | | Some(i) => i,
|
||||
LL | | };
|
||||
| |_____^ help: replace with: `Some(1).unwrap_or(42)`
|
||||
|
||||
error: this pattern reimplements `Option::unwrap_or_else`
|
||||
--> $DIR/manual_unwrap_or.rs:18:5
|
||||
|
|
||||
LL | / match Some(1) {
|
||||
LL | | Some(i) => i,
|
||||
|
|
@ -18,8 +27,8 @@ LL | | None => 1 + 42,
|
|||
LL | | };
|
||||
| |_____^ help: replace with: `Some(1).unwrap_or_else(|| 1 + 42)`
|
||||
|
||||
error: this pattern can be more concisely encoded with `Option::unwrap_or`
|
||||
--> $DIR/less_concise_than.rs:19:5
|
||||
error: this pattern reimplements `Option::unwrap_or_else`
|
||||
--> $DIR/manual_unwrap_or.rs:24:5
|
||||
|
|
||||
LL | / match Some(1) {
|
||||
LL | | Some(i) => i,
|
||||
|
|
@ -39,8 +48,8 @@ LL | b + 42
|
|||
LL | });
|
||||
|
|
||||
|
||||
error: this pattern can be more concisely encoded with `Option::unwrap_or`
|
||||
--> $DIR/less_concise_than.rs:29:5
|
||||
error: this pattern reimplements `Option::unwrap_or`
|
||||
--> $DIR/manual_unwrap_or.rs:34:5
|
||||
|
|
||||
LL | / match Some("Bob") {
|
||||
LL | | Some(i) => i,
|
||||
|
|
@ -48,5 +57,5 @@ LL | | None => "Alice",
|
|||
LL | | };
|
||||
| |_____^ help: replace with: `Some("Bob").unwrap_or("Alice")`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
#![allow(
|
||||
unused_parens,
|
||||
unused_variables,
|
||||
clippy::less_concise_than_option_unwrap_or,
|
||||
clippy::manual_unwrap_or,
|
||||
clippy::missing_docs_in_private_items,
|
||||
clippy::single_match
|
||||
)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue