about summary refs log tree commit diff
diff options
context:
space:
mode:
authorThibsG <Thibs@debian.com>2020-05-03 19:58:27 +0200
committerThibaud Genty <thibaud.genty@cosmian.com>2020-05-15 09:17:39 +0200
commit93386563f66823ac7d10641c007b0bbc23ab09e6 (patch)
treef1418b72011edb8616b2b8a7ff36725a0e7b624e
parentadbdf7549c6b24c37629eabdc4be0346e0c8fd56 (diff)
downloadrust-93386563f66823ac7d10641c007b0bbc23ab09e6.tar.gz
rust-93386563f66823ac7d10641c007b0bbc23ab09e6.zip
Rename lint `map_unwrap` to `map_unwrap_or` and register lints as renamed
-rw-r--r--CHANGELOG.md3
-rw-r--r--clippy_lints/src/lib.rs15
-rw-r--r--clippy_lints/src/methods/mod.rs8
-rw-r--r--clippy_lints/src/methods/option_map_unwrap_or.rs4
-rw-r--r--src/lintlist/mod.rs9
-rw-r--r--tests/ui/map_unwrap_or.rs (renamed from tests/ui/map_unwrap.rs)2
-rw-r--r--tests/ui/map_unwrap_or.stderr (renamed from tests/ui/map_unwrap.stderr)28
7 files changed, 36 insertions, 33 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3f9486e0972..77272f4f78b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1430,7 +1430,7 @@ Released 2018-09-13
 [`map_clone`]: https://rust-lang.github.io/rust-clippy/master/index.html#map_clone
 [`map_entry`]: https://rust-lang.github.io/rust-clippy/master/index.html#map_entry
 [`map_flatten`]: https://rust-lang.github.io/rust-clippy/master/index.html#map_flatten
-[`map_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#map_unwrap
+[`map_unwrap_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#map_unwrap_or
 [`match_as_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_as_ref
 [`match_bool`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_bool
 [`match_on_vec_items`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_on_vec_items
@@ -1538,7 +1538,6 @@ Released 2018-09-13
 [`rest_pat_in_fully_bound_structs`]: https://rust-lang.github.io/rust-clippy/master/index.html#rest_pat_in_fully_bound_structs
 [`result_map_or_into_option`]: https://rust-lang.github.io/rust-clippy/master/index.html#result_map_or_into_option
 [`result_map_unit_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#result_map_unit_fn
-[`result_unwrap_used`]: https://rust-lang.github.io/rust-clippy/master/index.html#result_unwrap_used
 [`reversed_empty_ranges`]: https://rust-lang.github.io/rust-clippy/master/index.html#reversed_empty_ranges
 [`same_functions_in_if_condition`]: https://rust-lang.github.io/rust-clippy/master/index.html#same_functions_in_if_condition
 [`search_is_some`]: https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some
diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs
index 8de94d19d31..ff67ccae794 100644
--- a/clippy_lints/src/lib.rs
+++ b/clippy_lints/src/lib.rs
@@ -673,7 +673,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
         &methods::ITER_SKIP_NEXT,
         &methods::MANUAL_SATURATING_ARITHMETIC,
         &methods::MAP_FLATTEN,
-        &methods::MAP_UNWRAP,
+        &methods::MAP_UNWRAP_OR,
         &methods::NEW_RET_NO_SELF,
         &methods::OK_EXPECT,
         &methods::OPTION_AND_THEN_SOME,
@@ -1145,7 +1145,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
         LintId::of(&methods::FIND_MAP),
         LintId::of(&methods::INEFFICIENT_TO_STRING),
         LintId::of(&methods::MAP_FLATTEN),
-        LintId::of(&methods::MAP_UNWRAP),
+        LintId::of(&methods::MAP_UNWRAP_OR),
         LintId::of(&misc::USED_UNDERSCORE_BINDING),
         LintId::of(&misc_early::UNSEPARATED_LITERAL_SUFFIX),
         LintId::of(&mut_mut::MUT_MUT),
@@ -1785,6 +1785,17 @@ pub fn register_renamed(ls: &mut rustc_lint::LintStore) {
     ls.register_renamed("clippy::new_without_default_derive", "clippy::new_without_default");
     ls.register_renamed("clippy::cyclomatic_complexity", "clippy::cognitive_complexity");
     ls.register_renamed("clippy::const_static_lifetime", "clippy::redundant_static_lifetimes");
+    ls.register_renamed("clippy::block_in_if_condition_expr", "clippy::block_in_if_condition");
+    ls.register_renamed("clippy::block_in_if_condition_stmt", "clippy::block_in_if_condition");
+    ls.register_renamed("clippy::option_map_unwrap_or", "clippy::map_unwrap_or");
+    ls.register_renamed("clippy::option_map_unwrap_or_else", "clippy::map_unwrap_or");
+    ls.register_renamed("clippy::result_map_unwrap_or_else", "clippy::map_unwrap_or");
+    ls.register_renamed("clippy::option_unwrap_used", "clippy::unwrap_used");
+    ls.register_renamed("clippy::result_unwrap_used", "clippy::unwrap_used");
+    ls.register_renamed("clippy::option_expect_used", "clippy::expect_used");
+    ls.register_renamed("clippy::result_expect_used", "clippy::expect_used");
+    ls.register_renamed("clippy::for_loop_over_option", "clippy::for_loop_over_fallible");
+    ls.register_renamed("clippy::for_loop_over_result", "clippy::for_loop_over_fallible");
 }
 
 // only exists to let the dogfood integration test works.
diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs
index 2e75de019b6..e6094edc5d7 100644
--- a/clippy_lints/src/methods/mod.rs
+++ b/clippy_lints/src/methods/mod.rs
@@ -255,7 +255,7 @@ declare_clippy_lint! {
     /// // Good
     /// x.map_or_else(some_function, |a| a + 1);
     /// ```
-    pub MAP_UNWRAP,
+    pub MAP_UNWRAP_OR,
     pedantic,
     "using `.map(f).unwrap_or(a)` or `.map(f).unwrap_or_else(func)`, which are more succinctly expressed as `map_or(a, f)` or `map_or_else(a, f)`"
 }
@@ -1240,7 +1240,7 @@ declare_lint_pass!(Methods => [
     WRONG_SELF_CONVENTION,
     WRONG_PUB_SELF_CONVENTION,
     OK_EXPECT,
-    MAP_UNWRAP,
+    MAP_UNWRAP_OR,
     RESULT_MAP_OR_INTO_OPTION,
     OPTION_MAP_OR_NONE,
     OPTION_AND_THEN_SOME,
@@ -2512,7 +2512,7 @@ fn lint_map_unwrap_or_else<'a, 'tcx>(
         if same_span && !multiline {
             span_lint_and_note(
                 cx,
-                MAP_UNWRAP,
+                MAP_UNWRAP_OR,
                 expr.span,
                 msg,
                 None,
@@ -2522,7 +2522,7 @@ fn lint_map_unwrap_or_else<'a, 'tcx>(
                 ),
             );
         } else if same_span && multiline {
-            span_lint(cx, MAP_UNWRAP, expr.span, msg);
+            span_lint(cx, MAP_UNWRAP_OR, expr.span, msg);
         };
     }
 }
diff --git a/clippy_lints/src/methods/option_map_unwrap_or.rs b/clippy_lints/src/methods/option_map_unwrap_or.rs
index fcaa9b47e64..20c60ef3318 100644
--- a/clippy_lints/src/methods/option_map_unwrap_or.rs
+++ b/clippy_lints/src/methods/option_map_unwrap_or.rs
@@ -9,7 +9,7 @@ use rustc_middle::hir::map::Map;
 use rustc_span::source_map::Span;
 use rustc_span::symbol::Symbol;
 
-use super::MAP_UNWRAP;
+use super::MAP_UNWRAP_OR;
 
 /// lint use of `map().unwrap_or()` for `Option`s
 pub(super) fn lint<'a, 'tcx>(
@@ -66,7 +66,7 @@ pub(super) fn lint<'a, 'tcx>(
             arg, suggest
         );
 
-        span_lint_and_then(cx, MAP_UNWRAP, expr.span, msg, |diag| {
+        span_lint_and_then(cx, MAP_UNWRAP_OR, expr.span, msg, |diag| {
             let map_arg_span = map_args[1].span;
 
             let mut suggestion = vec![
diff --git a/src/lintlist/mod.rs b/src/lintlist/mod.rs
index 0ea0f55a381..e90b9c15747 100644
--- a/src/lintlist/mod.rs
+++ b/src/lintlist/mod.rs
@@ -1138,7 +1138,7 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
         module: "methods",
     },
     Lint {
-        name: "map_unwrap",
+        name: "map_unwrap_or",
         group: "pedantic",
         desc: "using `.map(f).unwrap_or(a)` or `.map(f).unwrap_or_else(func)`, which are more succinctly expressed as `map_or(a, f)` or `map_or_else(a, f)`",
         deprecation: None,
@@ -1873,13 +1873,6 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
         module: "map_unit_fn",
     },
     Lint {
-        name: "result_unwrap_used",
-        group: "restriction",
-        desc: "using `Result.unwrap()`, which might be better handled",
-        deprecation: None,
-        module: "methods",
-    },
-    Lint {
         name: "reversed_empty_ranges",
         group: "correctness",
         desc: "reversing the limits of range expressions, resulting in empty ranges",
diff --git a/tests/ui/map_unwrap.rs b/tests/ui/map_unwrap_or.rs
index 53e50368231..585944032e7 100644
--- a/tests/ui/map_unwrap.rs
+++ b/tests/ui/map_unwrap_or.rs
@@ -1,7 +1,7 @@
 // FIXME: Add "run-rustfix" once it's supported for multipart suggestions
 // aux-build:option_helpers.rs
 
-#![warn(clippy::map_unwrap)]
+#![warn(clippy::map_unwrap_or)]
 
 #[macro_use]
 extern crate option_helpers;
diff --git a/tests/ui/map_unwrap.stderr b/tests/ui/map_unwrap_or.stderr
index 2610923275d..b62080a073f 100644
--- a/tests/ui/map_unwrap.stderr
+++ b/tests/ui/map_unwrap_or.stderr
@@ -1,5 +1,5 @@
 error: called `map(f).unwrap_or(a)` on an `Option` value. This can be done more directly by calling `map_or(a, f)` instead
-  --> $DIR/map_unwrap.rs:17:13
+  --> $DIR/map_unwrap_or.rs:17:13
    |
 LL |       let _ = opt.map(|x| x + 1)
    |  _____________^
@@ -7,14 +7,14 @@ LL | |         // Should lint even though this call is on a separate line.
 LL | |         .unwrap_or(0);
    | |_____________________^
    |
-   = note: `-D clippy::map-unwrap` implied by `-D warnings`
+   = note: `-D clippy::map-unwrap-or` implied by `-D warnings`
 help: use `map_or(a, f)` instead
    |
 LL |     let _ = opt.map_or(0, |x| x + 1);
    |                 ^^^^^^ ^^          --
 
 error: called `map(f).unwrap_or(a)` on an `Option` value. This can be done more directly by calling `map_or(a, f)` instead
-  --> $DIR/map_unwrap.rs:21:13
+  --> $DIR/map_unwrap_or.rs:21:13
    |
 LL |       let _ = opt.map(|x| {
    |  _____________^
@@ -32,7 +32,7 @@ LL |     );
    |
 
 error: called `map(f).unwrap_or(a)` on an `Option` value. This can be done more directly by calling `map_or(a, f)` instead
-  --> $DIR/map_unwrap.rs:25:13
+  --> $DIR/map_unwrap_or.rs:25:13
    |
 LL |       let _ = opt.map(|x| x + 1)
    |  _____________^
@@ -49,7 +49,7 @@ LL |         }, |x| x + 1);
    |
 
 error: called `map(f).unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then(f)` instead
-  --> $DIR/map_unwrap.rs:30:13
+  --> $DIR/map_unwrap_or.rs:30:13
    |
 LL |     let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -60,7 +60,7 @@ LL |     let _ = opt.and_then(|x| Some(x + 1));
    |                 ^^^^^^^^                --
 
 error: called `map(f).unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then(f)` instead
-  --> $DIR/map_unwrap.rs:32:13
+  --> $DIR/map_unwrap_or.rs:32:13
    |
 LL |       let _ = opt.map(|x| {
    |  _____________^
@@ -78,7 +78,7 @@ LL |     );
    |
 
 error: called `map(f).unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then(f)` instead
-  --> $DIR/map_unwrap.rs:36:13
+  --> $DIR/map_unwrap_or.rs:36:13
    |
 LL |       let _ = opt
    |  _____________^
@@ -92,7 +92,7 @@ LL |         .and_then(|x| Some(x + 1));
    |          ^^^^^^^^                --
 
 error: called `map(f).unwrap_or(a)` on an `Option` value. This can be done more directly by calling `map_or(a, f)` instead
-  --> $DIR/map_unwrap.rs:47:13
+  --> $DIR/map_unwrap_or.rs:47:13
    |
 LL |     let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -103,7 +103,7 @@ LL |     let _ = Some("prefix").map_or(id, |p| format!("{}.", p));
    |                            ^^^^^^ ^^^                      --
 
 error: called `map(f).unwrap_or_else(g)` on an `Option` value. This can be done more directly by calling `map_or_else(g, f)` instead
-  --> $DIR/map_unwrap.rs:51:13
+  --> $DIR/map_unwrap_or.rs:51:13
    |
 LL |       let _ = opt.map(|x| x + 1)
    |  _____________^
@@ -114,7 +114,7 @@ LL | |         .unwrap_or_else(|| 0);
    = note: replace `map(|x| x + 1).unwrap_or_else(|| 0)` with `map_or_else(|| 0, |x| x + 1)`
 
 error: called `map(f).unwrap_or_else(g)` on an `Option` value. This can be done more directly by calling `map_or_else(g, f)` instead
-  --> $DIR/map_unwrap.rs:55:13
+  --> $DIR/map_unwrap_or.rs:55:13
    |
 LL |       let _ = opt.map(|x| {
    |  _____________^
@@ -124,7 +124,7 @@ LL | |     ).unwrap_or_else(|| 0);
    | |__________________________^
 
 error: called `map(f).unwrap_or_else(g)` on an `Option` value. This can be done more directly by calling `map_or_else(g, f)` instead
-  --> $DIR/map_unwrap.rs:59:13
+  --> $DIR/map_unwrap_or.rs:59:13
    |
 LL |       let _ = opt.map(|x| x + 1)
    |  _____________^
@@ -134,7 +134,7 @@ LL | |         );
    | |_________^
 
 error: called `map(f).unwrap_or_else(g)` on a `Result` value. This can be done more directly by calling `.map_or_else(g, f)` instead
-  --> $DIR/map_unwrap.rs:88:13
+  --> $DIR/map_unwrap_or.rs:88:13
    |
 LL |     let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0); // should lint even though this call is on a separate line
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -142,7 +142,7 @@ LL |     let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0); // should lint even t
    = note: replace `map(|x| x + 1).unwrap_or_else(|e| 0)` with `map_or_else(|e| 0, |x| x + 1)`
 
 error: called `map(f).unwrap_or_else(g)` on a `Result` value. This can be done more directly by calling `.map_or_else(g, f)` instead
-  --> $DIR/map_unwrap.rs:90:13
+  --> $DIR/map_unwrap_or.rs:90:13
    |
 LL |     let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -150,7 +150,7 @@ LL |     let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0);
    = note: replace `map(|x| x + 1).unwrap_or_else(|e| 0)` with `map_or_else(|e| 0, |x| x + 1)`
 
 error: called `map(f).unwrap_or_else(g)` on a `Result` value. This can be done more directly by calling `.map_or_else(g, f)` instead
-  --> $DIR/map_unwrap.rs:91:13
+  --> $DIR/map_unwrap_or.rs:91:13
    |
 LL |     let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^