Skip to content

Commit 8188c46

Browse files
committed
Allow option_map_unwrap_or(_else)
This fixes #1192.
1 parent 8babb2d commit 8188c46

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ name
283283
[nonsensical_open_options](https://github.com/Manishearth/rust-clippy/wiki#nonsensical_open_options) | warn | nonsensical combination of options for opening a file
284284
[not_unsafe_ptr_arg_deref](https://github.com/Manishearth/rust-clippy/wiki#not_unsafe_ptr_arg_deref) | warn | public functions dereferencing raw pointer arguments but not marked `unsafe`
285285
[ok_expect](https://github.com/Manishearth/rust-clippy/wiki#ok_expect) | warn | using `ok().expect()`, which gives worse error messages than calling `expect` directly on the Result
286-
[option_map_unwrap_or](https://github.com/Manishearth/rust-clippy/wiki#option_map_unwrap_or) | warn | using `Option.map(f).unwrap_or(a)`, which is more succinctly expressed as `map_or(a, f)`
287-
[option_map_unwrap_or_else](https://github.com/Manishearth/rust-clippy/wiki#option_map_unwrap_or_else) | warn | using `Option.map(f).unwrap_or_else(g)`, which is more succinctly expressed as `map_or_else(g, f)`
286+
[option_map_unwrap_or](https://github.com/Manishearth/rust-clippy/wiki#option_map_unwrap_or) | allow | using `Option.map(f).unwrap_or(a)`, which is more succinctly expressed as `map_or(a, f)`
287+
[option_map_unwrap_or_else](https://github.com/Manishearth/rust-clippy/wiki#option_map_unwrap_or_else) | allow | using `Option.map(f).unwrap_or_else(g)`, which is more succinctly expressed as `map_or_else(g, f)`
288288
[option_unwrap_used](https://github.com/Manishearth/rust-clippy/wiki#option_unwrap_used) | allow | using `Option.unwrap()`, which should at least get a better message using `expect()`
289289
[or_fun_call](https://github.com/Manishearth/rust-clippy/wiki#or_fun_call) | warn | using any `*or` method with a function call, which suggests `*or_else`
290290
[out_of_bounds_indexing](https://github.com/Manishearth/rust-clippy/wiki#out_of_bounds_indexing) | deny | out of bounds constant indexing

clippy_lints/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
271271
matches::SINGLE_MATCH_ELSE,
272272
mem_forget::MEM_FORGET,
273273
methods::FILTER_MAP,
274+
methods::OPTION_MAP_UNWRAP_OR,
275+
methods::OPTION_MAP_UNWRAP_OR_ELSE,
274276
methods::OPTION_UNWRAP_USED,
275277
methods::RESULT_UNWRAP_USED,
276278
methods::WRONG_PUB_SELF_CONVENTION,
@@ -370,8 +372,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
370372
methods::ITER_NTH,
371373
methods::NEW_RET_NO_SELF,
372374
methods::OK_EXPECT,
373-
methods::OPTION_MAP_UNWRAP_OR,
374-
methods::OPTION_MAP_UNWRAP_OR_ELSE,
375375
methods::OR_FUN_CALL,
376376
methods::SEARCH_IS_SOME,
377377
methods::SHOULD_IMPLEMENT_TRAIT,

clippy_lints/src/methods.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ declare_lint! {
168168
/// ```
169169
declare_lint! {
170170
pub OPTION_MAP_UNWRAP_OR,
171-
Warn,
171+
Allow,
172172
"using `Option.map(f).unwrap_or(a)`, which is more succinctly expressed as \
173173
`map_or(a, f)`"
174174
}
@@ -186,7 +186,7 @@ declare_lint! {
186186
/// ```
187187
declare_lint! {
188188
pub OPTION_MAP_UNWRAP_OR_ELSE,
189-
Warn,
189+
Allow,
190190
"using `Option.map(f).unwrap_or_else(g)`, which is more succinctly expressed as \
191191
`map_or_else(g, f)`"
192192
}

0 commit comments

Comments
 (0)