-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thing
Description
clippy 0.0.212 (b2601be 2018-11-27)
I had this code which did not trigger any lints:
let input = match directory {
Some(value) => value,
None => {
return Err((
ErrorKind::RemoveDirNoArg,
"No argument assigned to --remove-dir, example: 'git-repos,registry-sources'"
.to_string(),
))
}
};
After applying rustfmt, an additional ;
was added:
let input = match directory {
Some(value) => value,
None => {
return Err((
ErrorKind::RemoveDirNoArg,
"No argument assigned to --remove-dir, example: 'git-repos,registry-sources'"
.to_string(),
)); // <--------- HERE
}
};
which caused clippy::single_match_else to trigger.
warning: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
--> src/library.rs:432:17
|
432 | let input = match directory {
| _________________^
433 | | Some(value) => value,
434 | | None => {
435 | | return Err((
... |
440 | | }
441 | | };
| |_____^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match_else
help: try this
|
432 | let input = if let Some(value) = directory { value } else {
433 | return Err((
434 | ErrorKind::RemoveDirNoArg,
435 | "No argument assigned to --remove-dir, example: 'git-repos,registry-sources'"
436 | .to_string(),
437 | ));
...
I think the link should also trigger on the unformatted example!
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thing