forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#5401 - dtolnay:option, r=Manishearth
Downgrade option_option to pedantic Based on a search of my work codebase (\>500k lines) for `Option<Option<`, it looks like a bunch of reasonable uses to me. The documented motivation for this lint is: > an optional optional value is logically the same thing as an optional value but has an unneeded extra level of wrapping which seems a bit bogus in practice. For example a typical usage would look like: ```rust let mut host: Option<String> = None; let mut port: Option<i32> = None; let mut payload: Option<Option<String>> = None; for each field { match field.name { "host" => host = Some(...), "port" => port = Some(...), "payload" => payload = Some(...), // can be null or string _ => return error, } } let host = host.ok_or(...)?; let port = port.ok_or(...)?; let payload = payload.ok_or(...)?; do_thing(host, port, payload) ``` This lint seems to fit right in with the pedantic group; I don't think linting on occurrences of `Option<Option<T>>` by default is justified. --- changelog: Remove option_option from default set of enabled lints
- Loading branch information
Showing
5 changed files
with
19 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#![deny(clippy::option_option)] | ||
|
||
fn input(_: Option<Option<u8>>) {} | ||
|
||
fn output() -> Option<Option<u8>> { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters