about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--clippy_lints/src/declared_lints.rs2
-rw-r--r--clippy_lints/src/lib.rs4
-rw-r--r--clippy_lints/src/manual_unwrap_or_default.rs (renamed from clippy_lints/src/match_option_and_default.rs)12
-rw-r--r--tests/ui/manual_unwrap_or_default.fixed (renamed from tests/ui/match_option_and_default.fixed)2
-rw-r--r--tests/ui/manual_unwrap_or_default.rs (renamed from tests/ui/match_option_and_default.rs)2
-rw-r--r--tests/ui/manual_unwrap_or_default.stderr (renamed from tests/ui/match_option_and_default.stderr)14
-rw-r--r--tests/ui/option_option.rs2
8 files changed, 19 insertions, 21 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2a9688b4b51..3bb3ef15d5b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5377,6 +5377,7 @@ Released 2018-09-13
 [`manual_swap`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_swap
 [`manual_try_fold`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_try_fold
 [`manual_unwrap_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or
+[`manual_unwrap_or_default`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or_default
 [`manual_while_let_some`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_while_let_some
 [`many_single_char_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#many_single_char_names
 [`map_clone`]: https://rust-lang.github.io/rust-clippy/master/index.html#map_clone
@@ -5390,7 +5391,6 @@ Released 2018-09-13
 [`match_bool`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_bool
 [`match_like_matches_macro`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro
 [`match_on_vec_items`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_on_vec_items
-[`match_option_and_default`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_option_and_default
 [`match_overlapping_arm`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_overlapping_arm
 [`match_ref_pats`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_ref_pats
 [`match_result_ok`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_result_ok
diff --git a/clippy_lints/src/declared_lints.rs b/clippy_lints/src/declared_lints.rs
index b9b03862b7b..0ccfd34494e 100644
--- a/clippy_lints/src/declared_lints.rs
+++ b/clippy_lints/src/declared_lints.rs
@@ -310,9 +310,9 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
     crate::manual_slice_size_calculation::MANUAL_SLICE_SIZE_CALCULATION_INFO,
     crate::manual_string_new::MANUAL_STRING_NEW_INFO,
     crate::manual_strip::MANUAL_STRIP_INFO,
+    crate::manual_unwrap_or_default::MANUAL_UNWRAP_OR_DEFAULT_INFO,
     crate::map_unit_fn::OPTION_MAP_UNIT_FN_INFO,
     crate::map_unit_fn::RESULT_MAP_UNIT_FN_INFO,
-    crate::match_option_and_default::MATCH_OPTION_AND_DEFAULT_INFO,
     crate::match_result_ok::MATCH_RESULT_OK_INFO,
     crate::matches::COLLAPSIBLE_MATCH_INFO,
     crate::matches::INFALLIBLE_DESTRUCTURING_MATCH_INFO,
diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs
index 589deb0e232..70292d3440e 100644
--- a/clippy_lints/src/lib.rs
+++ b/clippy_lints/src/lib.rs
@@ -211,8 +211,8 @@ mod manual_retain;
 mod manual_slice_size_calculation;
 mod manual_string_new;
 mod manual_strip;
+mod manual_unwrap_or_default;
 mod map_unit_fn;
-mod match_option_and_default;
 mod match_result_ok;
 mod matches;
 mod mem_replace;
@@ -1123,7 +1123,7 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
     store.register_early_pass(|| Box::new(multiple_bound_locations::MultipleBoundLocations));
     store.register_late_pass(|_| Box::new(assigning_clones::AssigningClones));
     store.register_late_pass(|_| Box::new(zero_repeat_side_effects::ZeroRepeatSideEffects));
-    store.register_late_pass(|_| Box::new(match_option_and_default::MatchOptionAndDefault));
+    store.register_late_pass(|_| Box::new(manual_unwrap_or_default::ManualUnwrapOrDefault));
     // add lints here, do not remove this comment, it's used in `new_lint`
 }
 
diff --git a/clippy_lints/src/match_option_and_default.rs b/clippy_lints/src/manual_unwrap_or_default.rs
index c39f6e93ebd..ddaf97c463a 100644
--- a/clippy_lints/src/match_option_and_default.rs
+++ b/clippy_lints/src/manual_unwrap_or_default.rs
@@ -42,12 +42,12 @@ declare_clippy_lint! {
     /// let y: Vec<String> = x.unwrap_or_default();
     /// ```
     #[clippy::version = "1.78.0"]
-    pub MATCH_OPTION_AND_DEFAULT,
+    pub MANUAL_UNWRAP_OR_DEFAULT,
     suspicious,
     "check if a `match` or `if let` can be simplified with `unwrap_or_default`"
 }
 
-declare_lint_pass!(MatchOptionAndDefault => [MATCH_OPTION_AND_DEFAULT]);
+declare_lint_pass!(ManualUnwrapOrDefault => [MANUAL_UNWRAP_OR_DEFAULT]);
 
 fn get_some<'tcx>(cx: &LateContext<'tcx>, pat: &Pat<'tcx>) -> Option<HirId> {
     if let PatKind::TupleStruct(QPath::Resolved(_, path), &[pat], _) = pat.kind
@@ -123,13 +123,12 @@ fn handle_match<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> bool {
         && local_id == binding_id
         // We now check the `None` arm is calling a method equivalent to `Default::default`.
         && let body_none = body_none.peel_blocks()
-        && let ExprKind::Call(_, &[]) = body_none.kind
         && is_default_equivalent(cx, body_none)
         && let Some(match_expr_snippet) = snippet_opt(cx, match_expr.span)
     {
         span_lint_and_sugg(
             cx,
-            MATCH_OPTION_AND_DEFAULT,
+            MANUAL_UNWRAP_OR_DEFAULT,
             expr.span,
             "match can be simplified with `.unwrap_or_default()`",
             "replace it with",
@@ -155,13 +154,12 @@ fn handle_if_let<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
         && local_id == binding_id
         // We now check the `None` arm is calling a method equivalent to `Default::default`.
         && let body_else = else_expr.peel_blocks()
-        && let ExprKind::Call(_, &[]) = body_else.kind
         && is_default_equivalent(cx, body_else)
         && let Some(if_let_expr_snippet) = snippet_opt(cx, let_.init.span)
     {
         span_lint_and_sugg(
             cx,
-            MATCH_OPTION_AND_DEFAULT,
+            MANUAL_UNWRAP_OR_DEFAULT,
             expr.span,
             "if let can be simplified with `.unwrap_or_default()`",
             "replace it with",
@@ -171,7 +169,7 @@ fn handle_if_let<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
     }
 }
 
-impl<'tcx> LateLintPass<'tcx> for MatchOptionAndDefault {
+impl<'tcx> LateLintPass<'tcx> for ManualUnwrapOrDefault {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
         if expr.span.from_expansion() {
             return;
diff --git a/tests/ui/match_option_and_default.fixed b/tests/ui/manual_unwrap_or_default.fixed
index 0a90ef636e8..c8456805ee6 100644
--- a/tests/ui/match_option_and_default.fixed
+++ b/tests/ui/manual_unwrap_or_default.fixed
@@ -1,4 +1,4 @@
-#![warn(clippy::match_option_and_default)]
+#![warn(clippy::manual_unwrap_or_default)]
 #![allow(clippy::unnecessary_literal_unwrap)]
 
 fn main() {
diff --git a/tests/ui/match_option_and_default.rs b/tests/ui/manual_unwrap_or_default.rs
index 8e69ef47431..820717be53a 100644
--- a/tests/ui/match_option_and_default.rs
+++ b/tests/ui/manual_unwrap_or_default.rs
@@ -1,4 +1,4 @@
-#![warn(clippy::match_option_and_default)]
+#![warn(clippy::manual_unwrap_or_default)]
 #![allow(clippy::unnecessary_literal_unwrap)]
 
 fn main() {
diff --git a/tests/ui/match_option_and_default.stderr b/tests/ui/manual_unwrap_or_default.stderr
index 86d7294f95a..f4eb6583588 100644
--- a/tests/ui/match_option_and_default.stderr
+++ b/tests/ui/manual_unwrap_or_default.stderr
@@ -1,5 +1,5 @@
 error: match can be simplified with `.unwrap_or_default()`
-  --> tests/ui/match_option_and_default.rs:6:5
+  --> tests/ui/manual_unwrap_or_default.rs:6:5
    |
 LL | /     match x {
 LL | |
@@ -8,11 +8,11 @@ LL | |         None => Vec::default(),
 LL | |     };
    | |_____^ help: replace it with: `x.unwrap_or_default()`
    |
-   = note: `-D clippy::match-option-and-default` implied by `-D warnings`
-   = help: to override `-D warnings` add `#[allow(clippy::match_option_and_default)]`
+   = note: `-D clippy::manual-unwrap-or-default` implied by `-D warnings`
+   = help: to override `-D warnings` add `#[allow(clippy::manual_unwrap_or_default)]`
 
 error: match can be simplified with `.unwrap_or_default()`
-  --> tests/ui/match_option_and_default.rs:13:5
+  --> tests/ui/manual_unwrap_or_default.rs:13:5
    |
 LL | /     match x {
 LL | |
@@ -22,7 +22,7 @@ LL | |     };
    | |_____^ help: replace it with: `x.unwrap_or_default()`
 
 error: match can be simplified with `.unwrap_or_default()`
-  --> tests/ui/match_option_and_default.rs:20:5
+  --> tests/ui/manual_unwrap_or_default.rs:20:5
    |
 LL | /     match x {
 LL | |
@@ -32,7 +32,7 @@ LL | |     };
    | |_____^ help: replace it with: `x.unwrap_or_default()`
 
 error: match can be simplified with `.unwrap_or_default()`
-  --> tests/ui/match_option_and_default.rs:27:5
+  --> tests/ui/manual_unwrap_or_default.rs:27:5
    |
 LL | /     match x {
 LL | |
@@ -42,7 +42,7 @@ LL | |     };
    | |_____^ help: replace it with: `x.unwrap_or_default()`
 
 error: if let can be simplified with `.unwrap_or_default()`
-  --> tests/ui/match_option_and_default.rs:34:5
+  --> tests/ui/manual_unwrap_or_default.rs:34:5
    |
 LL | /     if let Some(v) = x {
 LL | |
diff --git a/tests/ui/option_option.rs b/tests/ui/option_option.rs
index 7dda139c88e..8eb75428ca5 100644
--- a/tests/ui/option_option.rs
+++ b/tests/ui/option_option.rs
@@ -1,7 +1,7 @@
 //@compile-flags: -Zdeduplicate-diagnostics=yes
 
 #![deny(clippy::option_option)]
-#![allow(clippy::unnecessary_wraps, clippy::match_option_and_default)]
+#![allow(clippy::unnecessary_wraps, clippy::manual_unwrap_or_default)]
 
 const C: Option<Option<i32>> = None;
 //~^ ERROR: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if