]> git.lizzy.rs Git - rust.git/commitdiff
Allow option_map_unwrap_or(_else)
authorAndre Bogus <bogusandre@gmail.com>
Sun, 2 Oct 2016 19:23:26 +0000 (21:23 +0200)
committerAndre Bogus <bogusandre@gmail.com>
Sun, 2 Oct 2016 19:23:26 +0000 (21:23 +0200)
This fixes #1192.

README.md
clippy_lints/src/lib.rs
clippy_lints/src/methods.rs

index 7d6ed96681a5701c384339f3b6a57086137229e2..8b119ecf627482279c84ab4abac4e8f62c07c802 100644 (file)
--- a/README.md
+++ b/README.md
@@ -283,8 +283,8 @@ name
 [nonsensical_open_options](https://github.com/Manishearth/rust-clippy/wiki#nonsensical_open_options)                 | warn    | nonsensical combination of options for opening a file
 [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`
 [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
-[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)`
-[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)`
+[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)`
+[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)`
 [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()`
 [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`
 [out_of_bounds_indexing](https://github.com/Manishearth/rust-clippy/wiki#out_of_bounds_indexing)                     | deny    | out of bounds constant indexing
index fd42d91f41d9fb12ec040f844fda6c101a66f11f..4cfd27c9453a5f33692b80a1982c87c2f24ccb29 100644 (file)
@@ -271,6 +271,8 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
         matches::SINGLE_MATCH_ELSE,
         mem_forget::MEM_FORGET,
         methods::FILTER_MAP,
+        methods::OPTION_MAP_UNWRAP_OR,
+        methods::OPTION_MAP_UNWRAP_OR_ELSE,
         methods::OPTION_UNWRAP_USED,
         methods::RESULT_UNWRAP_USED,
         methods::WRONG_PUB_SELF_CONVENTION,
@@ -370,8 +372,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
         methods::ITER_NTH,
         methods::NEW_RET_NO_SELF,
         methods::OK_EXPECT,
-        methods::OPTION_MAP_UNWRAP_OR,
-        methods::OPTION_MAP_UNWRAP_OR_ELSE,
         methods::OR_FUN_CALL,
         methods::SEARCH_IS_SOME,
         methods::SHOULD_IMPLEMENT_TRAIT,
index a0a1059ba4896d57ba0368b68f633294f2cf4d65..13664e7d9129393147cb3124594047f9cbae8cac 100644 (file)
 /// ```
 declare_lint! {
     pub OPTION_MAP_UNWRAP_OR,
-    Warn,
+    Allow,
     "using `Option.map(f).unwrap_or(a)`, which is more succinctly expressed as \
      `map_or(a, f)`"
 }
 /// ```
 declare_lint! {
     pub OPTION_MAP_UNWRAP_OR_ELSE,
-    Warn,
+    Allow,
     "using `Option.map(f).unwrap_or_else(g)`, which is more succinctly expressed as \
      `map_or_else(g, f)`"
 }