about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-06-12 18:04:22 +0000
committerbors <bors@rust-lang.org>2023-06-12 18:04:22 +0000
commit7c2bf28365fb3867ecefa2c04da0fc6317b88e38 (patch)
tree8c9e8d0f563a9a9141f5af830e69b9cc79ded349
parentda56c3502ace00cfdef77af38cead0b9802e97fb (diff)
parentbfd5abad4b1b93133796a07a52ece3f7aa053062 (diff)
downloadrust-7c2bf28365fb3867ecefa2c04da0fc6317b88e38.tar.gz
rust-7c2bf28365fb3867ecefa2c04da0fc6317b88e38.zip
Auto merge of #10358 - pksunkara:unnecessary-unwrap, r=llogiq
Add `unnecessary_literal_unwrap` lint

Add lint for more unnecessary unwraps and suggest fixes for them.

Fixes #10352

- [x] Followed [lint naming conventions][lint_naming]
- [x] Added passing UI tests (including committed `.stderr` file)
- [x] `cargo test` passes locally
- [x] Executed `cargo dev update_lints`
- [x] Added lint documentation
- [x] Run `cargo dev fmt`

r? `@llogiq`

---

changelog: New lint [`unnecessary_literal_unwrap`]
[#10358](https://github.com/rust-lang/rust-clippy/pull/10358)
<!-- changelog_checked -->
-rw-r--r--CHANGELOG.md1
-rw-r--r--clippy_lints/src/declared_lints.rs1
-rw-r--r--clippy_lints/src/methods/mod.rs95
-rw-r--r--clippy_lints/src/methods/unnecessary_literal_unwrap.rs95
-rw-r--r--tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.fixed1
-rw-r--r--tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs1
-rw-r--r--tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr12
-rw-r--r--tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs1
-rw-r--r--tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.stderr18
-rw-r--r--tests/ui-toml/expect_used/expect_used.rs1
-rw-r--r--tests/ui-toml/expect_used/expect_used.stderr4
-rw-r--r--tests/ui/assertions_on_result_states.fixed1
-rw-r--r--tests/ui/assertions_on_result_states.rs1
-rw-r--r--tests/ui/assertions_on_result_states.stderr14
-rw-r--r--tests/ui/blocks_in_if_conditions_closure.rs7
-rw-r--r--tests/ui/blocks_in_if_conditions_closure.stderr4
-rw-r--r--tests/ui/checked_unwrap/complex_conditionals.rs6
-rw-r--r--tests/ui/checked_unwrap/complex_conditionals.stderr40
-rw-r--r--tests/ui/checked_unwrap/complex_conditionals_nested.rs6
-rw-r--r--tests/ui/checked_unwrap/complex_conditionals_nested.stderr4
-rw-r--r--tests/ui/checked_unwrap/simple_conditionals.rs6
-rw-r--r--tests/ui/checked_unwrap/simple_conditionals.stderr34
-rw-r--r--tests/ui/crashes/ice-5579.rs2
-rw-r--r--tests/ui/err_expect.fixed2
-rw-r--r--tests/ui/err_expect.rs2
-rw-r--r--tests/ui/expect.rs1
-rw-r--r--tests/ui/expect.stderr6
-rw-r--r--tests/ui/expect_fun_call.fixed6
-rw-r--r--tests/ui/expect_fun_call.rs6
-rw-r--r--tests/ui/expect_fun_call.stderr30
-rw-r--r--tests/ui/explicit_deref_methods.fixed3
-rw-r--r--tests/ui/explicit_deref_methods.rs3
-rw-r--r--tests/ui/explicit_deref_methods.stderr24
-rw-r--r--tests/ui/manual_unwrap_or.fixed2
-rw-r--r--tests/ui/manual_unwrap_or.rs2
-rw-r--r--tests/ui/missing_panics_doc.rs2
-rw-r--r--tests/ui/needless_borrow.fixed3
-rw-r--r--tests/ui/needless_borrow.rs3
-rw-r--r--tests/ui/needless_borrow.stderr72
-rw-r--r--tests/ui/needless_range_loop.rs6
-rw-r--r--tests/ui/needless_range_loop.stderr28
-rw-r--r--tests/ui/ok_expect.rs2
-rw-r--r--tests/ui/ok_expect.stderr10
-rw-r--r--tests/ui/or_fun_call.fixed1
-rw-r--r--tests/ui/or_fun_call.rs1
-rw-r--r--tests/ui/or_fun_call.stderr56
-rw-r--r--tests/ui/or_then_unwrap.fixed2
-rw-r--r--tests/ui/or_then_unwrap.rs2
-rw-r--r--tests/ui/redundant_clone.fixed7
-rw-r--r--tests/ui/redundant_clone.rs7
-rw-r--r--tests/ui/redundant_clone.stderr60
-rw-r--r--tests/ui/uninlined_format_args.fixed7
-rw-r--r--tests/ui/uninlined_format_args.rs7
-rw-r--r--tests/ui/uninlined_format_args.stderr142
-rw-r--r--tests/ui/unnecessary_lazy_eval.fixed1
-rw-r--r--tests/ui/unnecessary_lazy_eval.rs1
-rw-r--r--tests/ui/unnecessary_lazy_eval.stderr76
-rw-r--r--tests/ui/unnecessary_lazy_eval_unfixable.rs1
-rw-r--r--tests/ui/unnecessary_lazy_eval_unfixable.stderr6
-rw-r--r--tests/ui/unnecessary_literal_unwrap.fixed78
-rw-r--r--tests/ui/unnecessary_literal_unwrap.rs78
-rw-r--r--tests/ui/unnecessary_literal_unwrap.stderr413
-rw-r--r--tests/ui/unnecessary_literal_unwrap_unfixable.rs116
-rw-r--r--tests/ui/unnecessary_literal_unwrap_unfixable.stderr603
-rw-r--r--tests/ui/unwrap.rs1
-rw-r--r--tests/ui/unwrap.stderr6
-rw-r--r--tests/ui/unwrap_expect_used.rs1
-rw-r--r--tests/ui/unwrap_expect_used.stderr12
-rw-r--r--tests/ui/unwrap_or.rs1
-rw-r--r--tests/ui/unwrap_or.stderr4
-rw-r--r--tests/ui/unwrap_or_else_default.fixed2
-rw-r--r--tests/ui/unwrap_or_else_default.rs2
72 files changed, 1883 insertions, 379 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 85fddc97047..abc35e8546f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5248,6 +5248,7 @@ Released 2018-09-13
 [`unnecessary_fold`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_fold
 [`unnecessary_join`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_join
 [`unnecessary_lazy_evaluations`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations
+[`unnecessary_literal_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_literal_unwrap
 [`unnecessary_mut_passed`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_mut_passed
 [`unnecessary_operation`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_operation
 [`unnecessary_owned_empty_strings`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_owned_empty_strings
diff --git a/clippy_lints/src/declared_lints.rs b/clippy_lints/src/declared_lints.rs
index 523faa302dc..62317dc60eb 100644
--- a/clippy_lints/src/declared_lints.rs
+++ b/clippy_lints/src/declared_lints.rs
@@ -408,6 +408,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
     crate::methods::UNNECESSARY_FOLD_INFO,
     crate::methods::UNNECESSARY_JOIN_INFO,
     crate::methods::UNNECESSARY_LAZY_EVALUATIONS_INFO,
+    crate::methods::UNNECESSARY_LITERAL_UNWRAP_INFO,
     crate::methods::UNNECESSARY_SORT_BY_INFO,
     crate::methods::UNNECESSARY_TO_OWNED_INFO,
     crate::methods::UNWRAP_OR_ELSE_DEFAULT_INFO,
diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs
index 88cbefbb5d3..183bd582a48 100644
--- a/clippy_lints/src/methods/mod.rs
+++ b/clippy_lints/src/methods/mod.rs
@@ -93,6 +93,7 @@ mod unnecessary_fold;
 mod unnecessary_iter_cloned;
 mod unnecessary_join;
 mod unnecessary_lazy_eval;
+mod unnecessary_literal_unwrap;
 mod unnecessary_sort_by;
 mod unnecessary_to_owned;
 mod unwrap_or_else_default;
@@ -275,6 +276,32 @@ declare_clippy_lint! {
 
 declare_clippy_lint! {
     /// ### What it does
+    /// Checks for `.unwrap()` related calls on `Result`s and `Option`s that are constructed.
+    ///
+    /// ### Why is this bad?
+    /// It is better to write the value directly without the indirection.
+    ///
+    /// ### Examples
+    /// ```rust
+    /// let val1 = Some(1).unwrap();
+    /// let val2 = Ok::<_, ()>(1).unwrap();
+    /// let val3 = Err::<(), _>(1).unwrap_err();
+    /// ```
+    ///
+    /// Use instead:
+    /// ```rust
+    /// let val1 = 1;
+    /// let val2 = 1;
+    /// let val3 = 1;
+    /// ```
+    #[clippy::version = "1.69.0"]
+    pub UNNECESSARY_LITERAL_UNWRAP,
+    complexity,
+    "using `unwrap()` related calls on `Result` and `Option` constructors"
+}
+
+declare_clippy_lint! {
+    /// ### What it does
     /// Checks for `.expect()` or `.expect_err()` calls on `Result`s and `.expect()` call on `Option`s.
     ///
     /// ### Why is this bad?
@@ -3349,6 +3376,7 @@ impl_lint_pass!(Methods => [
     SUSPICIOUS_COMMAND_ARG_SPACE,
     CLEAR_WITH_DRAIN,
     MANUAL_NEXT_BACK,
+    UNNECESSARY_LITERAL_UNWRAP,
 ]);
 
 /// Extracts a method call name, args, and `Span` of the method name.
@@ -3606,12 +3634,18 @@ impl Methods {
                         case_sensitive_file_extension_comparisons::check(cx, expr, span, recv, arg);
                     }
                 },
-                ("expect", [_]) => match method_call(recv) {
-                    Some(("ok", recv, [], _, _)) => ok_expect::check(cx, expr, recv),
-                    Some(("err", recv, [], err_span, _)) => err_expect::check(cx, expr, recv, span, err_span, &self.msrv),
-                    _ => expect_used::check(cx, expr, recv, false, self.allow_expect_in_tests),
+                ("expect", [_]) => {
+                    match method_call(recv) {
+                        Some(("ok", recv, [], _, _)) => ok_expect::check(cx, expr, recv),
+                        Some(("err", recv, [], err_span, _)) => err_expect::check(cx, expr, recv, span, err_span, &self.msrv),
+                        _ => expect_used::check(cx, expr, recv, false, self.allow_expect_in_tests),
+                    }
+                    unnecessary_literal_unwrap::check(cx, expr, recv, name, args);
+                },
+                ("expect_err", [_]) => {
+                    unnecessary_literal_unwrap::check(cx, expr, recv, name, args);
+                    expect_used::check(cx, expr, recv, true, self.allow_expect_in_tests);
                 },
-                ("expect_err", [_]) => expect_used::check(cx, expr, recv, true, self.allow_expect_in_tests),
                 ("extend", [arg]) => {
                     string_extend_chars::check(cx, expr, recv, arg);
                     extend_with_drain::check(cx, expr, recv, arg);
@@ -3816,28 +3850,41 @@ impl Methods {
                         },
                         _ => {},
                     }
+                    unnecessary_literal_unwrap::check(cx, expr, recv, name, args);
                     unwrap_used::check(cx, expr, recv, false, self.allow_unwrap_in_tests);
                 },
-                ("unwrap_err", []) => unwrap_used::check(cx, expr, recv, true, self.allow_unwrap_in_tests),
-                ("unwrap_or", [u_arg]) => match method_call(recv) {
-                    Some((arith @ ("checked_add" | "checked_sub" | "checked_mul"), lhs, [rhs], _, _)) => {
-                        manual_saturating_arithmetic::check(cx, expr, lhs, rhs, u_arg, &arith["checked_".len()..]);
-                    },
-                    Some(("map", m_recv, [m_arg], span, _)) => {
-                        option_map_unwrap_or::check(cx, expr, m_recv, m_arg, recv, u_arg, span);
-                    },
-                    Some(("then_some", t_recv, [t_arg], _, _)) => {
-                        obfuscated_if_else::check(cx, expr, t_recv, t_arg, u_arg);
-                    },
-                    _ => {},
+                ("unwrap_err", []) => {
+                    unnecessary_literal_unwrap::check(cx, expr, recv, name, args);
+                    unwrap_used::check(cx, expr, recv, true, self.allow_unwrap_in_tests);
                 },
-                ("unwrap_or_else", [u_arg]) => match method_call(recv) {
-                    Some(("map", recv, [map_arg], _, _))
-                        if map_unwrap_or::check(cx, expr, recv, map_arg, u_arg, &self.msrv) => {},
-                    _ => {
-                        unwrap_or_else_default::check(cx, expr, recv, u_arg);
-                        unnecessary_lazy_eval::check(cx, expr, recv, u_arg, "unwrap_or");
-                    },
+                ("unwrap_or", [u_arg]) => {
+                    match method_call(recv) {
+                        Some((arith @ ("checked_add" | "checked_sub" | "checked_mul"), lhs, [rhs], _, _)) => {
+                            manual_saturating_arithmetic::check(cx, expr, lhs, rhs, u_arg, &arith["checked_".len()..]);
+                        },
+                        Some(("map", m_recv, [m_arg], span, _)) => {
+                            option_map_unwrap_or::check(cx, expr, m_recv, m_arg, recv, u_arg, span);
+                        },
+                        Some(("then_some", t_recv, [t_arg], _, _)) => {
+                            obfuscated_if_else::check(cx, expr, t_recv, t_arg, u_arg);
+                        },
+                        _ => {},
+                    }
+                    unnecessary_literal_unwrap::check(cx, expr, recv, name, args);
+                },
+                ("unwrap_or_default", []) => {
+                    unnecessary_literal_unwrap::check(cx, expr, recv, name, args);
+                }
+                ("unwrap_or_else", [u_arg]) => {
+                    match method_call(recv) {
+                        Some(("map", recv, [map_arg], _, _))
+                            if map_unwrap_or::check(cx, expr, recv, map_arg, u_arg, &self.msrv) => {},
+                        _ => {
+                            unwrap_or_else_default::check(cx, expr, recv, u_arg);
+                            unnecessary_lazy_eval::check(cx, expr, recv, u_arg, "unwrap_or");
+                        },
+                    }
+                    unnecessary_literal_unwrap::check(cx, expr, recv, name, args);
                 },
                 ("zip", [arg]) => {
                     if let ExprKind::MethodCall(name, iter_recv, [], _) = recv.kind
diff --git a/clippy_lints/src/methods/unnecessary_literal_unwrap.rs b/clippy_lints/src/methods/unnecessary_literal_unwrap.rs
new file mode 100644
index 00000000000..7877f6a386c
--- /dev/null
+++ b/clippy_lints/src/methods/unnecessary_literal_unwrap.rs
@@ -0,0 +1,95 @@
+use clippy_utils::{diagnostics::span_lint_and_then, is_res_lang_ctor, last_path_segment, path_res, MaybePath};
+use rustc_errors::Applicability;
+use rustc_hir as hir;
+use rustc_lint::LateContext;
+
+use super::UNNECESSARY_LITERAL_UNWRAP;
+
+fn get_ty_from_args<'a>(args: Option<&'a [hir::GenericArg<'a>]>, index: usize) -> Option<&'a hir::Ty<'a>> {
+    let args = args?;
+
+    if args.len() <= index {
+        return None;
+    }
+
+    match args[index] {
+        hir::GenericArg::Type(ty) => match ty.kind {
+            hir::TyKind::Infer => None,
+            _ => Some(ty),
+        },
+        _ => None,
+    }
+}
+
+pub(super) fn check(
+    cx: &LateContext<'_>,
+    expr: &hir::Expr<'_>,
+    recv: &hir::Expr<'_>,
+    method: &str,
+    args: &[hir::Expr<'_>],
+) {
+    let init = clippy_utils::expr_or_init(cx, recv);
+
+    let (constructor, call_args, ty) = if let hir::ExprKind::Call(call, call_args) = init.kind {
+        let Some(qpath) = call.qpath_opt() else { return };
+
+        let args = last_path_segment(qpath).args.map(|args| args.args);
+        let res = cx.qpath_res(qpath, call.hir_id());
+
+        if is_res_lang_ctor(cx, res, hir::LangItem::OptionSome) {
+            ("Some", call_args, get_ty_from_args(args, 0))
+        } else if is_res_lang_ctor(cx, res, hir::LangItem::ResultOk) {
+            ("Ok", call_args, get_ty_from_args(args, 0))
+        } else if is_res_lang_ctor(cx, res, hir::LangItem::ResultErr) {
+            ("Err", call_args, get_ty_from_args(args, 1))
+        } else {
+            return;
+        }
+    } else if is_res_lang_ctor(cx, path_res(cx, init), hir::LangItem::OptionNone) {
+        let call_args: &[hir::Expr<'_>] = &[];
+        ("None", call_args, None)
+    } else {
+        return;
+    };
+
+    let help_message = format!("used `{method}()` on `{constructor}` value");
+    let suggestion_message = format!("remove the `{constructor}` and `{method}()`");
+
+    span_lint_and_then(cx, UNNECESSARY_LITERAL_UNWRAP, expr.span, &help_message, |diag| {
+        let suggestions = match (constructor, method, ty) {
+            ("None", "unwrap", _) => Some(vec![(expr.span, "panic!()".to_string())]),
+            ("None", "expect", _) => Some(vec![
+                (expr.span.with_hi(args[0].span.lo()), "panic!(".to_string()),
+                (expr.span.with_lo(args[0].span.hi()), ")".to_string()),
+            ]),
+            (_, _, Some(_)) => None,
+            ("Ok", "unwrap_err", None) | ("Err", "unwrap", None) => Some(vec![
+                (
+                    recv.span.with_hi(call_args[0].span.lo()),
+                    "panic!(\"{:?}\", ".to_string(),
+                ),
+                (expr.span.with_lo(call_args[0].span.hi()), ")".to_string()),
+            ]),
+            ("Ok", "expect_err", None) | ("Err", "expect", None) => Some(vec![
+                (
+                    recv.span.with_hi(call_args[0].span.lo()),
+                    "panic!(\"{1}: {:?}\", ".to_string(),
+                ),
+                (call_args[0].span.with_lo(args[0].span.lo()), ", ".to_string()),
+            ]),
+            (_, _, None) => Some(vec![
+                (recv.span.with_hi(call_args[0].span.lo()), String::new()),
+                (expr.span.with_lo(call_args[0].span.hi()), String::new()),
+            ]),
+        };
+
+        match (init.span == recv.span, suggestions) {
+            (true, Some(suggestions)) => {
+                diag.multipart_suggestion(suggestion_message, suggestions, Applicability::MachineApplicable);
+            },
+            _ => {
+                diag.span_help(init.span, suggestion_message);
+            },
+        }
+    });
+}
diff --git a/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.fixed b/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.fixed
index 23e7bc16d23..c9085684528 100644
--- a/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.fixed
+++ b/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.fixed
@@ -1,5 +1,6 @@
 //@run-rustfix
 #![warn(clippy::uninlined_format_args)]
+#![allow(clippy::unnecessary_literal_unwrap)]
 
 fn main() {
     let local_i32 = 1;
diff --git a/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs b/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs
index d66b2b8ff6a..661350c5c6d 100644
--- a/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs
+++ b/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs
@@ -1,5 +1,6 @@
 //@run-rustfix
 #![warn(clippy::uninlined_format_args)]
+#![allow(clippy::unnecessary_literal_unwrap)]
 
 fn main() {
     let local_i32 = 1;
diff --git a/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr b/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr
index 1be0cda12fc..6ec79a618de 100644
--- a/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr
+++ b/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr
@@ -1,5 +1,5 @@
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:9:5
+  --> $DIR/uninlined_format_args.rs:10:5
    |
 LL |     println!("val='{}'", local_i32);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -12,7 +12,7 @@ LL +     println!("val='{local_i32}'");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:10:5
+  --> $DIR/uninlined_format_args.rs:11:5
    |
 LL |     println!("Hello {} is {:.*}", "x", local_i32, local_f64);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -24,7 +24,7 @@ LL +     println!("Hello {} is {local_f64:.local_i32$}", "x");
    |
 
 error: literal with an empty format string
-  --> $DIR/uninlined_format_args.rs:10:35
+  --> $DIR/uninlined_format_args.rs:11:35
    |
 LL |     println!("Hello {} is {:.*}", "x", local_i32, local_f64);
    |                                   ^^^
@@ -37,7 +37,7 @@ LL +     println!("Hello x is {:.*}", local_i32, local_f64);
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:11:5
+  --> $DIR/uninlined_format_args.rs:12:5
    |
 LL |     println!("Hello {} is {:.*}", local_i32, 5, local_f64);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -49,7 +49,7 @@ LL +     println!("Hello {local_i32} is {local_f64:.*}", 5);
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:12:5
+  --> $DIR/uninlined_format_args.rs:13:5
    |
 LL |     println!("Hello {} is {2:.*}", local_i32, 5, local_f64);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -61,7 +61,7 @@ LL +     println!("Hello {local_i32} is {local_f64:.*}", 5);
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:13:5
+  --> $DIR/uninlined_format_args.rs:14:5
    |
 LL |     println!("{}, {}", local_i32, local_opt.unwrap());
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs b/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs
index fb5b1b193f8..33f7c8ba804 100644
--- a/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs
+++ b/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs
@@ -1,4 +1,5 @@
 #![warn(clippy::arithmetic_side_effects)]
+#![allow(clippy::unnecessary_literal_unwrap)]
 
 use core::ops::{Add, Neg};
 
diff --git a/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.stderr b/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.stderr
index ad89534aa1b..4f98ca19231 100644
--- a/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.stderr
+++ b/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.stderr
@@ -1,5 +1,5 @@
 error: arithmetic operation that can potentially result in unexpected side-effects
-  --> $DIR/arithmetic_side_effects_allowed.rs:68:13
+  --> $DIR/arithmetic_side_effects_allowed.rs:69:13
    |
 LL |     let _ = Baz + Baz;
    |             ^^^^^^^^^
@@ -7,49 +7,49 @@ LL |     let _ = Baz + Baz;
    = note: `-D clippy::arithmetic-side-effects` implied by `-D warnings`
 
 error: arithmetic operation that can potentially result in unexpected side-effects
-  --> $DIR/arithmetic_side_effects_allowed.rs:79:13
+  --> $DIR/arithmetic_side_effects_allowed.rs:80:13
    |
 LL |     let _ = 1i32 + Baz;
    |             ^^^^^^^^^^
 
 error: arithmetic operation that can potentially result in unexpected side-effects
-  --> $DIR/arithmetic_side_effects_allowed.rs:82:13
+  --> $DIR/arithmetic_side_effects_allowed.rs:83:13
    |
 LL |     let _ = 1i64 + Foo;
    |             ^^^^^^^^^^
 
 error: arithmetic operation that can potentially result in unexpected side-effects
-  --> $DIR/arithmetic_side_effects_allowed.rs:86:13
+  --> $DIR/arithmetic_side_effects_allowed.rs:87:13
    |
 LL |     let _ = 1i64 + Baz;
    |             ^^^^^^^^^^
 
 error: arithmetic operation that can potentially result in unexpected side-effects
-  --> $DIR/arithmetic_side_effects_allowed.rs:97:13
+  --> $DIR/arithmetic_side_effects_allowed.rs:98:13
    |
 LL |     let _ = Baz + 1i32;
    |             ^^^^^^^^^^
 
 error: arithmetic operation that can potentially result in unexpected side-effects
-  --> $DIR/arithmetic_side_effects_allowed.rs:100:13
+  --> $DIR/arithmetic_side_effects_allowed.rs:101:13
    |
 LL |     let _ = Foo + 1i64;
    |             ^^^^^^^^^^
 
 error: arithmetic operation that can potentially result in unexpected side-effects
-  --> $DIR/arithmetic_side_effects_allowed.rs:104:13
+  --> $DIR/arithmetic_side_effects_allowed.rs:105:13
    |
 LL |     let _ = Baz + 1i64;
    |             ^^^^^^^^^^
 
 error: arithmetic operation that can potentially result in unexpected side-effects
-  --> $DIR/arithmetic_side_effects_allowed.rs:113:13
+  --> $DIR/arithmetic_side_effects_allowed.rs:114:13
    |
 LL |     let _ = -Bar;
    |             ^^^^
 
 error: arithmetic operation that can potentially result in unexpected side-effects
-  --> $DIR/arithmetic_side_effects_allowed.rs:115:13
+  --> $DIR/arithmetic_side_effects_allowed.rs:116:13
    |
 LL |     let _ = -Baz;
    |             ^^^^
diff --git a/tests/ui-toml/expect_used/expect_used.rs b/tests/ui-toml/expect_used/expect_used.rs
index 9e267c89300..206788e19f0 100644
--- a/tests/ui-toml/expect_used/expect_used.rs
+++ b/tests/ui-toml/expect_used/expect_used.rs
@@ -1,5 +1,6 @@
 //@compile-flags: --test
 #![warn(clippy::expect_used)]
+#![allow(clippy::unnecessary_literal_unwrap)]
 
 fn expect_option() {
     let opt = Some(0);
diff --git a/tests/ui-toml/expect_used/expect_used.stderr b/tests/ui-toml/expect_used/expect_used.stderr
index 1e9bb48c333..9eef0e1bfaa 100644
--- a/tests/ui-toml/expect_used/expect_used.stderr
+++ b/tests/ui-toml/expect_used/expect_used.stderr
@@ -1,5 +1,5 @@
 error: used `expect()` on an `Option` value
-  --> $DIR/expect_used.rs:6:13
+  --> $DIR/expect_used.rs:7:13
    |
 LL |     let _ = opt.expect("");
    |             ^^^^^^^^^^^^^^
@@ -8,7 +8,7 @@ LL |     let _ = opt.expect("");
    = note: `-D clippy::expect-used` implied by `-D warnings`
 
 error: used `expect()` on a `Result` value
-  --> $DIR/expect_used.rs:11:13
+  --> $DIR/expect_used.rs:12:13
    |
 LL |     let _ = res.expect("");
    |             ^^^^^^^^^^^^^^
diff --git a/tests/ui/assertions_on_result_states.fixed b/tests/ui/assertions_on_result_states.fixed
index ea8b895664c..3152bd3cae1 100644
--- a/tests/ui/assertions_on_result_states.fixed
+++ b/tests/ui/assertions_on_result_states.fixed
@@ -1,5 +1,6 @@
 //@run-rustfix
 #![warn(clippy::assertions_on_result_states)]
+#![allow(clippy::unnecessary_literal_unwrap)]
 
 use std::result::Result;
 
diff --git a/tests/ui/assertions_on_result_states.rs b/tests/ui/assertions_on_result_states.rs
index 6fc20f85988..42755e935aa 100644
--- a/tests/ui/assertions_on_result_states.rs
+++ b/tests/ui/assertions_on_result_states.rs
@@ -1,5 +1,6 @@
 //@run-rustfix
 #![warn(clippy::assertions_on_result_states)]
+#![allow(clippy::unnecessary_literal_unwrap)]
 
 use std::result::Result;
 
diff --git a/tests/ui/assertions_on_result_states.stderr b/tests/ui/assertions_on_result_states.stderr
index 298d63c9c34..be581030cb6 100644
--- a/tests/ui/assertions_on_result_states.stderr
+++ b/tests/ui/assertions_on_result_states.stderr
@@ -1,5 +1,5 @@
 error: called `assert!` with `Result::is_ok`
-  --> $DIR/assertions_on_result_states.rs:24:5
+  --> $DIR/assertions_on_result_states.rs:25:5
    |
 LL |     assert!(r.is_ok());
    |     ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()`
@@ -7,37 +7,37 @@ LL |     assert!(r.is_ok());
    = note: `-D clippy::assertions-on-result-states` implied by `-D warnings`
 
 error: called `assert!` with `Result::is_ok`
-  --> $DIR/assertions_on_result_states.rs:42:5
+  --> $DIR/assertions_on_result_states.rs:43:5
    |
 LL |     assert!(get_ok().is_ok());
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `get_ok().unwrap()`
 
 error: called `assert!` with `Result::is_ok`
-  --> $DIR/assertions_on_result_states.rs:45:5
+  --> $DIR/assertions_on_result_states.rs:46:5
    |
 LL |     assert!(get_ok_macro!().is_ok());
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `get_ok_macro!().unwrap()`
 
 error: called `assert!` with `Result::is_ok`
-  --> $DIR/assertions_on_result_states.rs:58:5
+  --> $DIR/assertions_on_result_states.rs:59:5
    |
 LL |     assert!(r.is_ok());
    |     ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()`
 
 error: called `assert!` with `Result::is_ok`
-  --> $DIR/assertions_on_result_states.rs:64:9
+  --> $DIR/assertions_on_result_states.rs:65:9
    |
 LL |         assert!(r.is_ok());
    |         ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()`
 
 error: called `assert!` with `Result::is_err`
-  --> $DIR/assertions_on_result_states.rs:72:5
+  --> $DIR/assertions_on_result_states.rs:73:5
    |
 LL |     assert!(r.is_err());
    |     ^^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap_err()`
 
 error: called `assert!` with `Result::is_err`
-  --> $DIR/assertions_on_result_states.rs:82:5
+  --> $DIR/assertions_on_result_states.rs:83:5
    |
 LL |     assert!(res.is_err())
    |     ^^^^^^^^^^^^^^^^^^^^^ help: replace with: `res.unwrap_err();`
diff --git a/tests/ui/blocks_in_if_conditions_closure.rs b/tests/ui/blocks_in_if_conditions_closure.rs
index 7da12d89a61..d6d085d7fd1 100644
--- a/tests/ui/blocks_in_if_conditions_closure.rs
+++ b/tests/ui/blocks_in_if_conditions_closure.rs
@@ -1,5 +1,10 @@
 #![warn(clippy::blocks_in_if_conditions)]
-#![allow(unused, clippy::let_and_return, clippy::needless_if)]
+#![allow(
+    unused,
+    clippy::let_and_return,
+    clippy::needless_if,
+    clippy::unnecessary_literal_unwrap
+)]
 
 fn predicate<F: FnOnce(T) -> bool, T>(pfn: F, val: T) -> bool {
     pfn(val)
diff --git a/tests/ui/blocks_in_if_conditions_closure.stderr b/tests/ui/blocks_in_if_conditions_closure.stderr
index 941d604dd5f..5ac02e7504e 100644
--- a/tests/ui/blocks_in_if_conditions_closure.stderr
+++ b/tests/ui/blocks_in_if_conditions_closure.stderr
@@ -1,5 +1,5 @@
 error: in an `if` condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let`
-  --> $DIR/blocks_in_if_conditions_closure.rs:18:17
+  --> $DIR/blocks_in_if_conditions_closure.rs:23:17
    |
 LL |               |x| {
    |  _________________^
@@ -11,7 +11,7 @@ LL | |             },
    = note: `-D clippy::blocks-in-if-conditions` implied by `-D warnings`
 
 error: in an `if` condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let`
-  --> $DIR/blocks_in_if_conditions_closure.rs:27:13
+  --> $DIR/blocks_in_if_conditions_closure.rs:32:13
    |
 LL |           |x| {
    |  _____________^
diff --git a/tests/ui/checked_unwrap/complex_conditionals.rs b/tests/ui/checked_unwrap/complex_conditionals.rs
index ec082c73b44..16e54a7d969 100644
--- a/tests/ui/checked_unwrap/complex_conditionals.rs
+++ b/tests/ui/checked_unwrap/complex_conditionals.rs
@@ -1,5 +1,9 @@
 #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
-#![allow(clippy::if_same_then_else, clippy::branches_sharing_code)]
+#![allow(
+    clippy::if_same_then_else,
+    clippy::branches_sharing_code,
+    clippy::unnecessary_literal_unwrap
+)]
 
 fn test_complex_conditions() {
     let x: Result<(), ()> = Ok(());
diff --git a/tests/ui/checked_unwrap/complex_conditionals.stderr b/tests/ui/checked_unwrap/complex_conditionals.stderr
index d44d5072e48..c395c5ba06f 100644
--- a/tests/ui/checked_unwrap/complex_conditionals.stderr
+++ b/tests/ui/checked_unwrap/complex_conditionals.stderr
@@ -1,5 +1,5 @@
 error: called `unwrap` on `x` after checking its variant with `is_ok`
-  --> $DIR/complex_conditionals.rs:8:9
+  --> $DIR/complex_conditionals.rs:12:9
    |
 LL |     if x.is_ok() && y.is_err() {
    |        --------- the check is happening here
@@ -14,7 +14,7 @@ LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
    |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: this call to `unwrap_err()` will always panic
-  --> $DIR/complex_conditionals.rs:9:9
+  --> $DIR/complex_conditionals.rs:13:9
    |
 LL |     if x.is_ok() && y.is_err() {
    |        --------- because of this check
@@ -29,7 +29,7 @@ LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
    |         ^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: this call to `unwrap()` will always panic
-  --> $DIR/complex_conditionals.rs:10:9
+  --> $DIR/complex_conditionals.rs:14:9
    |
 LL |     if x.is_ok() && y.is_err() {
    |                     ---------- because of this check
@@ -38,7 +38,7 @@ LL |         y.unwrap(); // will panic
    |         ^^^^^^^^^^
 
 error: called `unwrap_err` on `y` after checking its variant with `is_err`
-  --> $DIR/complex_conditionals.rs:11:9
+  --> $DIR/complex_conditionals.rs:15:9
    |
 LL |     if x.is_ok() && y.is_err() {
    |                     ---------- the check is happening here
@@ -49,7 +49,7 @@ LL |         y.unwrap_err(); // unnecessary
    = help: try using `if let` or `match`
 
 error: this call to `unwrap()` will always panic
-  --> $DIR/complex_conditionals.rs:25:9
+  --> $DIR/complex_conditionals.rs:29:9
    |
 LL |     if x.is_ok() || y.is_ok() {
    |        --------- because of this check
@@ -58,7 +58,7 @@ LL |         x.unwrap(); // will panic
    |         ^^^^^^^^^^
 
 error: called `unwrap_err` on `x` after checking its variant with `is_ok`
-  --> $DIR/complex_conditionals.rs:26:9
+  --> $DIR/complex_conditionals.rs:30:9
    |
 LL |     if x.is_ok() || y.is_ok() {
    |        --------- the check is happening here
@@ -69,7 +69,7 @@ LL |         x.unwrap_err(); // unnecessary
    = help: try using `if let` or `match`
 
 error: this call to `unwrap()` will always panic
-  --> $DIR/complex_conditionals.rs:27:9
+  --> $DIR/complex_conditionals.rs:31:9
    |
 LL |     if x.is_ok() || y.is_ok() {
    |                     --------- because of this check
@@ -78,7 +78,7 @@ LL |         y.unwrap(); // will panic
    |         ^^^^^^^^^^
 
 error: called `unwrap_err` on `y` after checking its variant with `is_ok`
-  --> $DIR/complex_conditionals.rs:28:9
+  --> $DIR/complex_conditionals.rs:32:9
    |
 LL |     if x.is_ok() || y.is_ok() {
    |                     --------- the check is happening here
@@ -89,7 +89,7 @@ LL |         y.unwrap_err(); // unnecessary
    = help: try using `if let` or `match`
 
 error: called `unwrap` on `x` after checking its variant with `is_ok`
-  --> $DIR/complex_conditionals.rs:32:9
+  --> $DIR/complex_conditionals.rs:36:9
    |
 LL |     if x.is_ok() && !(y.is_ok() || z.is_err()) {
    |        --------- the check is happening here
@@ -99,7 +99,7 @@ LL |         x.unwrap(); // unnecessary
    = help: try using `if let` or `match`
 
 error: this call to `unwrap_err()` will always panic
-  --> $DIR/complex_conditionals.rs:33:9
+  --> $DIR/complex_conditionals.rs:37:9
    |
 LL |     if x.is_ok() && !(y.is_ok() || z.is_err()) {
    |        --------- because of this check
@@ -108,7 +108,7 @@ LL |         x.unwrap_err(); // will panic
    |         ^^^^^^^^^^^^^^
 
 error: this call to `unwrap()` will always panic
-  --> $DIR/complex_conditionals.rs:34:9
+  --> $DIR/complex_conditionals.rs:38:9
    |
 LL |     if x.is_ok() && !(y.is_ok() || z.is_err()) {
    |                       --------- because of this check
@@ -117,7 +117,7 @@ LL |         y.unwrap(); // will panic
    |         ^^^^^^^^^^
 
 error: called `unwrap_err` on `y` after checking its variant with `is_ok`
-  --> $DIR/complex_conditionals.rs:35:9
+  --> $DIR/complex_conditionals.rs:39:9
    |
 LL |     if x.is_ok() && !(y.is_ok() || z.is_err()) {
    |                       --------- the check is happening here
@@ -128,7 +128,7 @@ LL |         y.unwrap_err(); // unnecessary
    = help: try using `if let` or `match`
 
 error: called `unwrap` on `z` after checking its variant with `is_err`
-  --> $DIR/complex_conditionals.rs:36:9
+  --> $DIR/complex_conditionals.rs:40:9
    |
 LL |     if x.is_ok() && !(y.is_ok() || z.is_err()) {
    |                                    ---------- the check is happening here
@@ -139,7 +139,7 @@ LL |         z.unwrap(); // unnecessary
    = help: try using `if let` or `match`
 
 error: this call to `unwrap_err()` will always panic
-  --> $DIR/complex_conditionals.rs:37:9
+  --> $DIR/complex_conditionals.rs:41:9
    |
 LL |     if x.is_ok() && !(y.is_ok() || z.is_err()) {
    |                                    ---------- because of this check
@@ -148,7 +148,7 @@ LL |         z.unwrap_err(); // will panic
    |         ^^^^^^^^^^^^^^
 
 error: this call to `unwrap()` will always panic
-  --> $DIR/complex_conditionals.rs:45:9
+  --> $DIR/complex_conditionals.rs:49:9
    |
 LL |     if x.is_ok() || !(y.is_ok() && z.is_err()) {
    |        --------- because of this check
@@ -157,7 +157,7 @@ LL |         x.unwrap(); // will panic
    |         ^^^^^^^^^^
 
 error: called `unwrap_err` on `x` after checking its variant with `is_ok`
-  --> $DIR/complex_conditionals.rs:46:9
+  --> $DIR/complex_conditionals.rs:50:9
    |
 LL |     if x.is_ok() || !(y.is_ok() && z.is_err()) {
    |        --------- the check is happening here
@@ -168,7 +168,7 @@ LL |         x.unwrap_err(); // unnecessary
    = help: try using `if let` or `match`
 
 error: called `unwrap` on `y` after checking its variant with `is_ok`
-  --> $DIR/complex_conditionals.rs:47:9
+  --> $DIR/complex_conditionals.rs:51:9
    |
 LL |     if x.is_ok() || !(y.is_ok() && z.is_err()) {
    |                       --------- the check is happening here
@@ -179,7 +179,7 @@ LL |         y.unwrap(); // unnecessary
    = help: try using `if let` or `match`
 
 error: this call to `unwrap_err()` will always panic
-  --> $DIR/complex_conditionals.rs:48:9
+  --> $DIR/complex_conditionals.rs:52:9
    |
 LL |     if x.is_ok() || !(y.is_ok() && z.is_err()) {
    |                       --------- because of this check
@@ -188,7 +188,7 @@ LL |         y.unwrap_err(); // will panic
    |         ^^^^^^^^^^^^^^
 
 error: this call to `unwrap()` will always panic
-  --> $DIR/complex_conditionals.rs:49:9
+  --> $DIR/complex_conditionals.rs:53:9
    |
 LL |     if x.is_ok() || !(y.is_ok() && z.is_err()) {
    |                                    ---------- because of this check
@@ -197,7 +197,7 @@ LL |         z.unwrap(); // will panic
    |         ^^^^^^^^^^
 
 error: called `unwrap_err` on `z` after checking its variant with `is_err`
-  --> $DIR/complex_conditionals.rs:50:9
+  --> $DIR/complex_conditionals.rs:54:9
    |
 LL |     if x.is_ok() || !(y.is_ok() && z.is_err()) {
    |                                    ---------- the check is happening here
diff --git a/tests/ui/checked_unwrap/complex_conditionals_nested.rs b/tests/ui/checked_unwrap/complex_conditionals_nested.rs
index 043ea4148dc..e417cf833cb 100644
--- a/tests/ui/checked_unwrap/complex_conditionals_nested.rs
+++ b/tests/ui/checked_unwrap/complex_conditionals_nested.rs
@@ -1,5 +1,9 @@
 #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
-#![allow(clippy::if_same_then_else, clippy::branches_sharing_code)]
+#![allow(
+    clippy::if_same_then_else,
+    clippy::branches_sharing_code,
+    clippy::unnecessary_literal_unwrap
+)]
 
 fn test_nested() {
     fn nested() {
diff --git a/tests/ui/checked_unwrap/complex_conditionals_nested.stderr b/tests/ui/checked_unwrap/complex_conditionals_nested.stderr
index 542ab53300c..049a69d93bf 100644
--- a/tests/ui/checked_unwrap/complex_conditionals_nested.stderr
+++ b/tests/ui/checked_unwrap/complex_conditionals_nested.stderr
@@ -1,5 +1,5 @@
 error: called `unwrap` on `x` after checking its variant with `is_some`
-  --> $DIR/complex_conditionals_nested.rs:8:13
+  --> $DIR/complex_conditionals_nested.rs:12:13
    |
 LL |         if x.is_some() {
    |         -------------- help: try: `if let Some(..) = x`
@@ -13,7 +13,7 @@ LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
    |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: this call to `unwrap()` will always panic
-  --> $DIR/complex_conditionals_nested.rs:10:13
+  --> $DIR/complex_conditionals_nested.rs:14:13
    |
 LL |         if x.is_some() {
    |            ----------- because of this check
diff --git a/tests/ui/checked_unwrap/simple_conditionals.rs b/tests/ui/checked_unwrap/simple_conditionals.rs
index 82dce81979f..61042bb90d2 100644
--- a/tests/ui/checked_unwrap/simple_conditionals.rs
+++ b/tests/ui/checked_unwrap/simple_conditionals.rs
@@ -1,6 +1,10 @@
 #![feature(lint_reasons)]
 #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
-#![allow(clippy::if_same_then_else, clippy::branches_sharing_code)]
+#![allow(
+    clippy::if_same_then_else,
+    clippy::branches_sharing_code,
+    clippy::unnecessary_literal_unwrap
+)]
 
 macro_rules! m {
     ($a:expr) => {
diff --git a/tests/ui/checked_unwrap/simple_conditionals.stderr b/tests/ui/checked_unwrap/simple_conditionals.stderr
index ef688274222..93809f6551a 100644
--- a/tests/ui/checked_unwrap/simple_conditionals.stderr
+++ b/tests/ui/checked_unwrap/simple_conditionals.stderr
@@ -1,5 +1,5 @@
 error: called `unwrap` on `x` after checking its variant with `is_some`
-  --> $DIR/simple_conditionals.rs:40:9
+  --> $DIR/simple_conditionals.rs:44:9
    |
 LL |     if x.is_some() {
    |     -------------- help: try: `if let Some(..) = x`
@@ -13,7 +13,7 @@ LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
    |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: called `expect` on `x` after checking its variant with `is_some`
-  --> $DIR/simple_conditionals.rs:41:9
+  --> $DIR/simple_conditionals.rs:45:9
    |
 LL |     if x.is_some() {
    |     -------------- help: try: `if let Some(..) = x`
@@ -22,7 +22,7 @@ LL |         x.expect("an error message"); // unnecessary
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: this call to `unwrap()` will always panic
-  --> $DIR/simple_conditionals.rs:43:9
+  --> $DIR/simple_conditionals.rs:47:9
    |
 LL |     if x.is_some() {
    |        ----------- because of this check
@@ -37,7 +37,7 @@ LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
    |         ^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: this call to `expect()` will always panic
-  --> $DIR/simple_conditionals.rs:44:9
+  --> $DIR/simple_conditionals.rs:48:9
    |
 LL |     if x.is_some() {
    |        ----------- because of this check
@@ -46,7 +46,7 @@ LL |         x.expect("an error message"); // will panic
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: this call to `unwrap()` will always panic
-  --> $DIR/simple_conditionals.rs:47:9
+  --> $DIR/simple_conditionals.rs:51:9
    |
 LL |     if x.is_none() {
    |        ----------- because of this check
@@ -54,7 +54,7 @@ LL |         x.unwrap(); // will panic
    |         ^^^^^^^^^^
 
 error: called `unwrap` on `x` after checking its variant with `is_none`
-  --> $DIR/simple_conditionals.rs:49:9
+  --> $DIR/simple_conditionals.rs:53:9
    |
 LL |     if x.is_none() {
    |     -------------- help: try: `if let Some(..) = x`
@@ -63,7 +63,7 @@ LL |         x.unwrap(); // unnecessary
    |         ^^^^^^^^^^
 
 error: called `unwrap` on `x` after checking its variant with `is_some`
-  --> $DIR/simple_conditionals.rs:8:13
+  --> $DIR/simple_conditionals.rs:12:13
    |
 LL |         if $a.is_some() {
    |         --------------- help: try: `if let Some(..) = x`
@@ -76,7 +76,7 @@ LL |     m!(x);
    = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: called `unwrap` on `x` after checking its variant with `is_ok`
-  --> $DIR/simple_conditionals.rs:57:9
+  --> $DIR/simple_conditionals.rs:61:9
    |
 LL |     if x.is_ok() {
    |     ------------ help: try: `if let Ok(..) = x`
@@ -84,7 +84,7 @@ LL |         x.unwrap(); // unnecessary
    |         ^^^^^^^^^^
 
 error: called `expect` on `x` after checking its variant with `is_ok`
-  --> $DIR/simple_conditionals.rs:58:9
+  --> $DIR/simple_conditionals.rs:62:9
    |
 LL |     if x.is_ok() {
    |     ------------ help: try: `if let Ok(..) = x`
@@ -93,7 +93,7 @@ LL |         x.expect("an error message"); // unnecessary
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: this call to `unwrap_err()` will always panic
-  --> $DIR/simple_conditionals.rs:59:9
+  --> $DIR/simple_conditionals.rs:63:9
    |
 LL |     if x.is_ok() {
    |        --------- because of this check
@@ -102,7 +102,7 @@ LL |         x.unwrap_err(); // will panic
    |         ^^^^^^^^^^^^^^
 
 error: this call to `unwrap()` will always panic
-  --> $DIR/simple_conditionals.rs:61:9
+  --> $DIR/simple_conditionals.rs:65:9
    |
 LL |     if x.is_ok() {
    |        --------- because of this check
@@ -111,7 +111,7 @@ LL |         x.unwrap(); // will panic
    |         ^^^^^^^^^^
 
 error: this call to `expect()` will always panic
-  --> $DIR/simple_conditionals.rs:62:9
+  --> $DIR/simple_conditionals.rs:66:9
    |
 LL |     if x.is_ok() {
    |        --------- because of this check
@@ -120,7 +120,7 @@ LL |         x.expect("an error message"); // will panic
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: called `unwrap_err` on `x` after checking its variant with `is_ok`
-  --> $DIR/simple_conditionals.rs:63:9
+  --> $DIR/simple_conditionals.rs:67:9
    |
 LL |     if x.is_ok() {
    |     ------------ help: try: `if let Err(..) = x`
@@ -129,7 +129,7 @@ LL |         x.unwrap_err(); // unnecessary
    |         ^^^^^^^^^^^^^^
 
 error: this call to `unwrap()` will always panic
-  --> $DIR/simple_conditionals.rs:66:9
+  --> $DIR/simple_conditionals.rs:70:9
    |
 LL |     if x.is_err() {
    |        ---------- because of this check
@@ -137,7 +137,7 @@ LL |         x.unwrap(); // will panic
    |         ^^^^^^^^^^
 
 error: called `unwrap_err` on `x` after checking its variant with `is_err`
-  --> $DIR/simple_conditionals.rs:67:9
+  --> $DIR/simple_conditionals.rs:71:9
    |
 LL |     if x.is_err() {
    |     ------------- help: try: `if let Err(..) = x`
@@ -146,7 +146,7 @@ LL |         x.unwrap_err(); // unnecessary
    |         ^^^^^^^^^^^^^^
 
 error: called `unwrap` on `x` after checking its variant with `is_err`
-  --> $DIR/simple_conditionals.rs:69:9
+  --> $DIR/simple_conditionals.rs:73:9
    |
 LL |     if x.is_err() {
    |     ------------- help: try: `if let Ok(..) = x`
@@ -155,7 +155,7 @@ LL |         x.unwrap(); // unnecessary
    |         ^^^^^^^^^^
 
 error: this call to `unwrap_err()` will always panic
-  --> $DIR/simple_conditionals.rs:70:9
+  --> $DIR/simple_conditionals.rs:74:9
    |
 LL |     if x.is_err() {
    |        ---------- because of this check
diff --git a/tests/ui/crashes/ice-5579.rs b/tests/ui/crashes/ice-5579.rs
index e1842c73f0e..8ab36bbf93c 100644
--- a/tests/ui/crashes/ice-5579.rs
+++ b/tests/ui/crashes/ice-5579.rs
@@ -1,3 +1,5 @@
+#![allow(clippy::unnecessary_literal_unwrap)]
+
 trait IsErr {
     fn is_err(&self, err: &str) -> bool;
 }
diff --git a/tests/ui/err_expect.fixed b/tests/ui/err_expect.fixed
index 6ade6f54689..46e2816da52 100644
--- a/tests/ui/err_expect.fixed
+++ b/tests/ui/err_expect.fixed
@@ -1,6 +1,6 @@
 //@run-rustfix
 
-#![allow(unused)]
+#![allow(unused, clippy::unnecessary_literal_unwrap)]
 
 struct MyTypeNonDebug;
 
diff --git a/tests/ui/err_expect.rs b/tests/ui/err_expect.rs
index a93fb59493f..b9446034d50 100644
--- a/tests/ui/err_expect.rs
+++ b/tests/ui/err_expect.rs
@@ -1,6 +1,6 @@
 //@run-rustfix
 
-#![allow(unused)]
+#![allow(unused, clippy::unnecessary_literal_unwrap)]
 
 struct MyTypeNonDebug;
 
diff --git a/tests/ui/expect.rs b/tests/ui/expect.rs
index d742595e14d..1588579bb0f 100644
--- a/tests/ui/expect.rs
+++ b/tests/ui/expect.rs
@@ -1,4 +1,5 @@
 #![warn(clippy::expect_used)]
+#![allow(clippy::unnecessary_literal_unwrap)]
 
 fn expect_option() {
     let opt = Some(0);
diff --git a/tests/ui/expect.stderr b/tests/ui/expect.stderr
index c08e0dbbf74..be340340d47 100644
--- a/tests/ui/expect.stderr
+++ b/tests/ui/expect.stderr
@@ -1,5 +1,5 @@
 error: used `expect()` on an `Option` value
-  --> $DIR/expect.rs:5:13
+  --> $DIR/expect.rs:6:13
    |
 LL |     let _ = opt.expect("");
    |             ^^^^^^^^^^^^^^
@@ -8,7 +8,7 @@ LL |     let _ = opt.expect("");
    = note: `-D clippy::expect-used` implied by `-D warnings`
 
 error: used `expect()` on a `Result` value
-  --> $DIR/expect.rs:10:13
+  --> $DIR/expect.rs:11:13
    |
 LL |     let _ = res.expect("");
    |             ^^^^^^^^^^^^^^
@@ -16,7 +16,7 @@ LL |     let _ = res.expect("");
    = help: if this value is an `Err`, it will panic
 
 error: used `expect_err()` on a `Result` value
-  --> $DIR/expect.rs:11:13
+  --> $DIR/expect.rs:12:13
    |
 LL |     let _ = res.expect_err("");
    |             ^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/expect_fun_call.fixed b/tests/ui/expect_fun_call.fixed
index 8e97054fb6b..73c6c97de84 100644
--- a/tests/ui/expect_fun_call.fixed
+++ b/tests/ui/expect_fun_call.fixed
@@ -1,6 +1,10 @@
 //@run-rustfix
 #![warn(clippy::expect_fun_call)]
-#![allow(clippy::to_string_in_format_args, clippy::uninlined_format_args)]
+#![allow(
+    clippy::to_string_in_format_args,
+    clippy::uninlined_format_args,
+    clippy::unnecessary_literal_unwrap
+)]
 
 /// Checks implementation of the `EXPECT_FUN_CALL` lint
 
diff --git a/tests/ui/expect_fun_call.rs b/tests/ui/expect_fun_call.rs
index 31e6bcc7ff6..a786138631c 100644
--- a/tests/ui/expect_fun_call.rs
+++ b/tests/ui/expect_fun_call.rs
@@ -1,6 +1,10 @@
 //@run-rustfix
 #![warn(clippy::expect_fun_call)]
-#![allow(clippy::to_string_in_format_args, clippy::uninlined_format_args)]
+#![allow(
+    clippy::to_string_in_format_args,
+    clippy::uninlined_format_args,
+    clippy::unnecessary_literal_unwrap
+)]
 
 /// Checks implementation of the `EXPECT_FUN_CALL` lint
 
diff --git a/tests/ui/expect_fun_call.stderr b/tests/ui/expect_fun_call.stderr
index cb55e32aee0..36fb0e5de15 100644
--- a/tests/ui/expect_fun_call.stderr
+++ b/tests/ui/expect_fun_call.stderr
@@ -1,5 +1,5 @@
 error: use of `expect` followed by a function call
-  --> $DIR/expect_fun_call.rs:34:26
+  --> $DIR/expect_fun_call.rs:38:26
    |
 LL |     with_none_and_format.expect(&format!("Error {}: fake error", error_code));
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("Error {}: fake error", error_code))`
@@ -7,85 +7,85 @@ LL |     with_none_and_format.expect(&format!("Error {}: fake error", error_code
    = note: `-D clippy::expect-fun-call` implied by `-D warnings`
 
 error: use of `expect` followed by a function call
-  --> $DIR/expect_fun_call.rs:37:26
+  --> $DIR/expect_fun_call.rs:41:26
    |
 LL |     with_none_and_as_str.expect(format!("Error {}: fake error", error_code).as_str());
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("Error {}: fake error", error_code))`
 
 error: use of `expect` followed by a function call
-  --> $DIR/expect_fun_call.rs:40:37
+  --> $DIR/expect_fun_call.rs:44:37
    |
 LL |     with_none_and_format_with_macro.expect(format!("Error {}: fake error", one!()).as_str());
    |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("Error {}: fake error", one!()))`
 
 error: use of `expect` followed by a function call
-  --> $DIR/expect_fun_call.rs:50:25
+  --> $DIR/expect_fun_call.rs:54:25
    |
 LL |     with_err_and_format.expect(&format!("Error {}: fake error", error_code));
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| panic!("Error {}: fake error", error_code))`
 
 error: use of `expect` followed by a function call
-  --> $DIR/expect_fun_call.rs:53:25
+  --> $DIR/expect_fun_call.rs:57:25
    |
 LL |     with_err_and_as_str.expect(format!("Error {}: fake error", error_code).as_str());
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| panic!("Error {}: fake error", error_code))`
 
 error: use of `expect` followed by a function call
-  --> $DIR/expect_fun_call.rs:65:17
+  --> $DIR/expect_fun_call.rs:69:17
    |
 LL |     Some("foo").expect(format!("{} {}", 1, 2).as_ref());
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("{} {}", 1, 2))`
 
 error: use of `expect` followed by a function call
-  --> $DIR/expect_fun_call.rs:86:21
+  --> $DIR/expect_fun_call.rs:90:21
    |
 LL |         Some("foo").expect(&get_string());
    |                     ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_string()) })`
 
 error: use of `expect` followed by a function call
-  --> $DIR/expect_fun_call.rs:87:21
+  --> $DIR/expect_fun_call.rs:91:21
    |
 LL |         Some("foo").expect(get_string().as_ref());
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_string()) })`
 
 error: use of `expect` followed by a function call
-  --> $DIR/expect_fun_call.rs:88:21
+  --> $DIR/expect_fun_call.rs:92:21
    |
 LL |         Some("foo").expect(get_string().as_str());
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_string()) })`
 
 error: use of `expect` followed by a function call
-  --> $DIR/expect_fun_call.rs:90:21
+  --> $DIR/expect_fun_call.rs:94:21
    |
 LL |         Some("foo").expect(get_static_str());
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_static_str()) })`
 
 error: use of `expect` followed by a function call
-  --> $DIR/expect_fun_call.rs:91:21
+  --> $DIR/expect_fun_call.rs:95:21
    |
 LL |         Some("foo").expect(get_non_static_str(&0));
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_non_static_str(&0).to_string()) })`
 
 error: use of `expect` followed by a function call
-  --> $DIR/expect_fun_call.rs:95:16
+  --> $DIR/expect_fun_call.rs:99:16
    |
 LL |     Some(true).expect(&format!("key {}, {}", 1, 2));
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("key {}, {}", 1, 2))`
 
 error: use of `expect` followed by a function call
-  --> $DIR/expect_fun_call.rs:101:17
+  --> $DIR/expect_fun_call.rs:105:17
    |
 LL |         opt_ref.expect(&format!("{:?}", opt_ref));
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("{:?}", opt_ref))`
 
 error: use of `expect` followed by a function call
-  --> $DIR/expect_fun_call.rs:105:20
+  --> $DIR/expect_fun_call.rs:109:20
    |
 LL |     format_capture.expect(&format!("{error_code}"));
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("{error_code}"))`
 
 error: use of `expect` followed by a function call
-  --> $DIR/expect_fun_call.rs:108:30
+  --> $DIR/expect_fun_call.rs:112:30
    |
 LL |     format_capture_and_value.expect(&format!("{error_code}, {}", 1));
    |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("{error_code}, {}", 1))`
diff --git a/tests/ui/explicit_deref_methods.fixed b/tests/ui/explicit_deref_methods.fixed
index 1710b170fb8..4d72b58cdf8 100644
--- a/tests/ui/explicit_deref_methods.fixed
+++ b/tests/ui/explicit_deref_methods.fixed
@@ -7,7 +7,8 @@
     clippy::explicit_auto_deref,
     clippy::needless_borrow,
     clippy::no_effect,
-    clippy::uninlined_format_args
+    clippy::uninlined_format_args,
+    clippy::unnecessary_literal_unwrap
 )]
 
 use std::ops::{Deref, DerefMut};
diff --git a/tests/ui/explicit_deref_methods.rs b/tests/ui/explicit_deref_methods.rs
index 85147e1cb69..fcd945de338 100644
--- a/tests/ui/explicit_deref_methods.rs
+++ b/tests/ui/explicit_deref_methods.rs
@@ -7,7 +7,8 @@
     clippy::explicit_auto_deref,
     clippy::needless_borrow,
     clippy::no_effect,
-    clippy::uninlined_format_args
+    clippy::uninlined_format_args,
+    clippy::unnecessary_literal_unwrap
 )]
 
 use std::ops::{Deref, DerefMut};
diff --git a/tests/ui/explicit_deref_methods.stderr b/tests/ui/explicit_deref_methods.stderr
index 592563ffa8c..d025035b789 100644
--- a/tests/ui/explicit_deref_methods.stderr
+++ b/tests/ui/explicit_deref_methods.stderr
@@ -1,5 +1,5 @@
 error: explicit `deref` method call
-  --> $DIR/explicit_deref_methods.rs:53:19
+  --> $DIR/explicit_deref_methods.rs:54:19
    |
 LL |     let b: &str = a.deref();
    |                   ^^^^^^^^^ help: try this: `&*a`
@@ -7,67 +7,67 @@ LL |     let b: &str = a.deref();
    = note: `-D clippy::explicit-deref-methods` implied by `-D warnings`
 
 error: explicit `deref_mut` method call
-  --> $DIR/explicit_deref_methods.rs:55:23
+  --> $DIR/explicit_deref_methods.rs:56:23
    |
 LL |     let b: &mut str = a.deref_mut();
    |                       ^^^^^^^^^^^^^ help: try this: `&mut **a`
 
 error: explicit `deref` method call
-  --> $DIR/explicit_deref_methods.rs:58:39
+  --> $DIR/explicit_deref_methods.rs:59:39
    |
 LL |     let b: String = format!("{}, {}", a.deref(), a.deref());
    |                                       ^^^^^^^^^ help: try this: `&*a`
 
 error: explicit `deref` method call
-  --> $DIR/explicit_deref_methods.rs:58:50
+  --> $DIR/explicit_deref_methods.rs:59:50
    |
 LL |     let b: String = format!("{}, {}", a.deref(), a.deref());
    |                                                  ^^^^^^^^^ help: try this: `&*a`
 
 error: explicit `deref` method call
-  --> $DIR/explicit_deref_methods.rs:60:20
+  --> $DIR/explicit_deref_methods.rs:61:20
    |
 LL |     println!("{}", a.deref());
    |                    ^^^^^^^^^ help: try this: `&*a`
 
 error: explicit `deref` method call
-  --> $DIR/explicit_deref_methods.rs:63:11
+  --> $DIR/explicit_deref_methods.rs:64:11
    |
 LL |     match a.deref() {
    |           ^^^^^^^^^ help: try this: `&*a`
 
 error: explicit `deref` method call
-  --> $DIR/explicit_deref_methods.rs:67:28
+  --> $DIR/explicit_deref_methods.rs:68:28
    |
 LL |     let b: String = concat(a.deref());
    |                            ^^^^^^^^^ help: try this: `&*a`
 
 error: explicit `deref` method call
-  --> $DIR/explicit_deref_methods.rs:69:13
+  --> $DIR/explicit_deref_methods.rs:70:13
    |
 LL |     let b = just_return(a).deref();
    |             ^^^^^^^^^^^^^^^^^^^^^^ help: try this: `just_return(a)`
 
 error: explicit `deref` method call
-  --> $DIR/explicit_deref_methods.rs:71:28
+  --> $DIR/explicit_deref_methods.rs:72:28
    |
 LL |     let b: String = concat(just_return(a).deref());
    |                            ^^^^^^^^^^^^^^^^^^^^^^ help: try this: `just_return(a)`
 
 error: explicit `deref` method call
-  --> $DIR/explicit_deref_methods.rs:73:19
+  --> $DIR/explicit_deref_methods.rs:74:19
    |
 LL |     let b: &str = a.deref().deref();
    |                   ^^^^^^^^^^^^^^^^^ help: try this: `&**a`
 
 error: explicit `deref` method call
-  --> $DIR/explicit_deref_methods.rs:76:13
+  --> $DIR/explicit_deref_methods.rs:77:13
    |
 LL |     let b = opt_a.unwrap().deref();
    |             ^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&*opt_a.unwrap()`
 
 error: explicit `deref` method call
-  --> $DIR/explicit_deref_methods.rs:113:31
+  --> $DIR/explicit_deref_methods.rs:114:31
    |
 LL |     let b: &str = expr_deref!(a.deref());
    |                               ^^^^^^^^^ help: try this: `&*a`
diff --git a/tests/ui/manual_unwrap_or.fixed b/tests/ui/manual_unwrap_or.fixed
index c17634bffe3..20560b87c1a 100644
--- a/tests/ui/manual_unwrap_or.fixed
+++ b/tests/ui/manual_unwrap_or.fixed
@@ -1,6 +1,6 @@
 //@run-rustfix
 #![allow(dead_code)]
-#![allow(unused_variables, clippy::unnecessary_wraps)]
+#![allow(unused_variables, clippy::unnecessary_wraps, clippy::unnecessary_literal_unwrap)]
 
 fn option_unwrap_or() {
     // int case
diff --git a/tests/ui/manual_unwrap_or.rs b/tests/ui/manual_unwrap_or.rs
index 6d49a6949fa..5dbc57565bf 100644
--- a/tests/ui/manual_unwrap_or.rs
+++ b/tests/ui/manual_unwrap_or.rs
@@ -1,6 +1,6 @@
 //@run-rustfix
 #![allow(dead_code)]
-#![allow(unused_variables, clippy::unnecessary_wraps)]
+#![allow(unused_variables, clippy::unnecessary_wraps, clippy::unnecessary_literal_unwrap)]
 
 fn option_unwrap_or() {
     // int case
diff --git a/tests/ui/missing_panics_doc.rs b/tests/ui/missing_panics_doc.rs
index 7dc44529206..10aa436d6cd 100644
--- a/tests/ui/missing_panics_doc.rs
+++ b/tests/ui/missing_panics_doc.rs
@@ -1,5 +1,5 @@
 #![warn(clippy::missing_panics_doc)]
-#![allow(clippy::option_map_unit_fn)]
+#![allow(clippy::option_map_unit_fn, clippy::unnecessary_literal_unwrap)]
 fn main() {}
 
 /// This needs to be documented
diff --git a/tests/ui/needless_borrow.fixed b/tests/ui/needless_borrow.fixed
index 425e6eb6200..80cdb4e472d 100644
--- a/tests/ui/needless_borrow.fixed
+++ b/tests/ui/needless_borrow.fixed
@@ -4,7 +4,8 @@
     unused,
     clippy::uninlined_format_args,
     clippy::unnecessary_mut_passed,
-    clippy::unnecessary_to_owned
+    clippy::unnecessary_to_owned,
+    clippy::unnecessary_literal_unwrap
 )]
 #![warn(clippy::needless_borrow)]
 
diff --git a/tests/ui/needless_borrow.rs b/tests/ui/needless_borrow.rs
index 3f7fa4a9d7d..99f735127eb 100644
--- a/tests/ui/needless_borrow.rs
+++ b/tests/ui/needless_borrow.rs
@@ -4,7 +4,8 @@
     unused,
     clippy::uninlined_format_args,
     clippy::unnecessary_mut_passed,
-    clippy::unnecessary_to_owned
+    clippy::unnecessary_to_owned,
+    clippy::unnecessary_literal_unwrap
 )]
 #![warn(clippy::needless_borrow)]
 
diff --git a/tests/ui/needless_borrow.stderr b/tests/ui/needless_borrow.stderr
index d26c317124b..f85b4fb46a6 100644
--- a/tests/ui/needless_borrow.stderr
+++ b/tests/ui/needless_borrow.stderr
@@ -1,5 +1,5 @@
 error: this expression creates a reference which is immediately dereferenced by the compiler
-  --> $DIR/needless_borrow.rs:15:15
+  --> $DIR/needless_borrow.rs:16:15
    |
 LL |     let _ = x(&&a); // warn
    |               ^^^ help: change this to: `&a`
@@ -7,211 +7,211 @@ LL |     let _ = x(&&a); // warn
    = note: `-D clippy::needless-borrow` implied by `-D warnings`
 
 error: this expression creates a reference which is immediately dereferenced by the compiler
-  --> $DIR/needless_borrow.rs:19:13
+  --> $DIR/needless_borrow.rs:20:13
    |
 LL |     mut_ref(&mut &mut b); // warn
    |             ^^^^^^^^^^^ help: change this to: `&mut b`
 
 error: this expression creates a reference which is immediately dereferenced by the compiler
-  --> $DIR/needless_borrow.rs:31:13
+  --> $DIR/needless_borrow.rs:32:13
    |
 LL |             &&a
    |             ^^^ help: change this to: `&a`
 
 error: this expression creates a reference which is immediately dereferenced by the compiler
-  --> $DIR/needless_borrow.rs:33:15
+  --> $DIR/needless_borrow.rs:34:15
    |
 LL |         46 => &&a,
    |               ^^^ help: change this to: `&a`
 
 error: this expression creates a reference which is immediately dereferenced by the compiler
-  --> $DIR/needless_borrow.rs:39:27
+  --> $DIR/needless_borrow.rs:40:27
    |
 LL |                     break &ref_a;
    |                           ^^^^^^ help: change this to: `ref_a`
 
 error: this expression creates a reference which is immediately dereferenced by the compiler
-  --> $DIR/needless_borrow.rs:46:15
+  --> $DIR/needless_borrow.rs:47:15
    |
 LL |     let _ = x(&&&a);
    |               ^^^^ help: change this to: `&a`
 
 error: this expression creates a reference which is immediately dereferenced by the compiler
-  --> $DIR/needless_borrow.rs:47:15
+  --> $DIR/needless_borrow.rs:48:15
    |
 LL |     let _ = x(&mut &&a);
    |               ^^^^^^^^ help: change this to: `&a`
 
 error: this expression creates a reference which is immediately dereferenced by the compiler
-  --> $DIR/needless_borrow.rs:48:15
+  --> $DIR/needless_borrow.rs:49:15
    |
 LL |     let _ = x(&&&mut b);
    |               ^^^^^^^^ help: change this to: `&mut b`
 
 error: this expression creates a reference which is immediately dereferenced by the compiler
-  --> $DIR/needless_borrow.rs:49:15
+  --> $DIR/needless_borrow.rs:50:15
    |
 LL |     let _ = x(&&ref_a);
    |               ^^^^^^^ help: change this to: `ref_a`
 
 error: this expression creates a reference which is immediately dereferenced by the compiler
-  --> $DIR/needless_borrow.rs:52:11
+  --> $DIR/needless_borrow.rs:53:11
    |
 LL |         x(&b);
    |           ^^ help: change this to: `b`
 
 error: this expression creates a reference which is immediately dereferenced by the compiler
-  --> $DIR/needless_borrow.rs:59:13
+  --> $DIR/needless_borrow.rs:60:13
    |
 LL |     mut_ref(&mut x);
    |             ^^^^^^ help: change this to: `x`
 
 error: this expression creates a reference which is immediately dereferenced by the compiler
-  --> $DIR/needless_borrow.rs:60:13
+  --> $DIR/needless_borrow.rs:61:13
    |
 LL |     mut_ref(&mut &mut x);
    |             ^^^^^^^^^^^ help: change this to: `x`
 
 error: this expression creates a reference which is immediately dereferenced by the compiler
-  --> $DIR/needless_borrow.rs:61:23
+  --> $DIR/needless_borrow.rs:62:23
    |
 LL |     let y: &mut i32 = &mut x;
    |                       ^^^^^^ help: change this to: `x`
 
 error: this expression creates a reference which is immediately dereferenced by the compiler
-  --> $DIR/needless_borrow.rs:62:23
+  --> $DIR/needless_borrow.rs:63:23
    |
 LL |     let y: &mut i32 = &mut &mut x;
    |                       ^^^^^^^^^^^ help: change this to: `x`
 
 error: this expression creates a reference which is immediately dereferenced by the compiler
-  --> $DIR/needless_borrow.rs:71:14
+  --> $DIR/needless_borrow.rs:72:14
    |
 LL |         0 => &mut x,
    |              ^^^^^^ help: change this to: `x`
 
 error: this expression creates a reference which is immediately dereferenced by the compiler
-  --> $DIR/needless_borrow.rs:77:14
+  --> $DIR/needless_borrow.rs:78:14
    |
 LL |         0 => &mut x,
    |              ^^^^^^ help: change this to: `x`
 
 error: this expression borrows a value the compiler would automatically borrow
-  --> $DIR/needless_borrow.rs:89:13
+  --> $DIR/needless_borrow.rs:90:13
    |
 LL |     let _ = (&x).0;
    |             ^^^^ help: change this to: `x`
 
 error: this expression borrows a value the compiler would automatically borrow
-  --> $DIR/needless_borrow.rs:91:22
+  --> $DIR/needless_borrow.rs:92:22
    |
 LL |     let _ = unsafe { (&*x).0 };
    |                      ^^^^^ help: change this to: `(*x)`
 
 error: this expression creates a reference which is immediately dereferenced by the compiler
-  --> $DIR/needless_borrow.rs:101:5
+  --> $DIR/needless_borrow.rs:102:5
    |
 LL |     (&&()).foo();
    |     ^^^^^^ help: change this to: `(&())`
 
 error: this expression creates a reference which is immediately dereferenced by the compiler
-  --> $DIR/needless_borrow.rs:110:5
+  --> $DIR/needless_borrow.rs:111:5
    |
 LL |     (&&5).foo();
    |     ^^^^^ help: change this to: `(&5)`
 
 error: the borrowed expression implements the required traits
-  --> $DIR/needless_borrow.rs:135:51
+  --> $DIR/needless_borrow.rs:136:51
    |
 LL |     let _ = std::process::Command::new("ls").args(&["-a", "-l"]).status().unwrap();
    |                                                   ^^^^^^^^^^^^^ help: change this to: `["-a", "-l"]`
 
 error: the borrowed expression implements the required traits
-  --> $DIR/needless_borrow.rs:136:44
+  --> $DIR/needless_borrow.rs:137:44
    |
 LL |     let _ = std::path::Path::new(".").join(&&".");
    |                                            ^^^^^ help: change this to: `"."`
 
 error: the borrowed expression implements the required traits
-  --> $DIR/needless_borrow.rs:137:23
+  --> $DIR/needless_borrow.rs:138:23
    |
 LL |     deref_target_is_x(&X);
    |                       ^^ help: change this to: `X`
 
 error: the borrowed expression implements the required traits
-  --> $DIR/needless_borrow.rs:138:26
+  --> $DIR/needless_borrow.rs:139:26
    |
 LL |     multiple_constraints(&[[""]]);
    |                          ^^^^^^^ help: change this to: `[[""]]`
 
 error: the borrowed expression implements the required traits
-  --> $DIR/needless_borrow.rs:139:45
+  --> $DIR/needless_borrow.rs:140:45
    |
 LL |     multiple_constraints_normalizes_to_same(&X, X);
    |                                             ^^ help: change this to: `X`
 
 error: this expression creates a reference which is immediately dereferenced by the compiler
-  --> $DIR/needless_borrow.rs:140:32
+  --> $DIR/needless_borrow.rs:141:32
    |
 LL |     let _ = Some("").unwrap_or(&"");
    |                                ^^^ help: change this to: `""`
 
 error: the borrowed expression implements the required traits
-  --> $DIR/needless_borrow.rs:141:33
+  --> $DIR/needless_borrow.rs:142:33
    |
 LL |     let _ = std::fs::write("x", &"".to_string());
    |                                 ^^^^^^^^^^^^^^^ help: change this to: `"".to_string()`
 
 error: this expression borrows a value the compiler would automatically borrow
-  --> $DIR/needless_borrow.rs:190:13
+  --> $DIR/needless_borrow.rs:191:13
    |
 LL |             (&self.f)()
    |             ^^^^^^^^^ help: change this to: `(self.f)`
 
 error: this expression borrows a value the compiler would automatically borrow
-  --> $DIR/needless_borrow.rs:199:13
+  --> $DIR/needless_borrow.rs:200:13
    |
 LL |             (&mut self.f)()
    |             ^^^^^^^^^^^^^ help: change this to: `(self.f)`
 
 error: the borrowed expression implements the required traits
-  --> $DIR/needless_borrow.rs:283:20
+  --> $DIR/needless_borrow.rs:284:20
    |
 LL |         takes_iter(&mut x)
    |                    ^^^^^^ help: change this to: `x`
 
 error: the borrowed expression implements the required traits
-  --> $DIR/needless_borrow.rs:297:55
+  --> $DIR/needless_borrow.rs:298:55
    |
 LL |         let _ = std::process::Command::new("ls").args(&["-a", "-l"]).status().unwrap();
    |                                                       ^^^^^^^^^^^^^ help: change this to: `["-a", "-l"]`
 
 error: the borrowed expression implements the required traits
-  --> $DIR/needless_borrow.rs:335:37
+  --> $DIR/needless_borrow.rs:336:37
    |
 LL |         let _ = std::fs::write("x", &arg);
    |                                     ^^^^ help: change this to: `arg`
 
 error: the borrowed expression implements the required traits
-  --> $DIR/needless_borrow.rs:336:37
+  --> $DIR/needless_borrow.rs:337:37
    |
 LL |         let _ = std::fs::write("x", &loc);
    |                                     ^^^^ help: change this to: `loc`
 
 error: the borrowed expression implements the required traits
-  --> $DIR/needless_borrow.rs:354:15
+  --> $DIR/needless_borrow.rs:355:15
    |
 LL |         debug(&x);
    |               ^^ help: change this to: `x`
 
 error: the borrowed expression implements the required traits
-  --> $DIR/needless_borrow.rs:363:15
+  --> $DIR/needless_borrow.rs:364:15
    |
 LL |         use_x(&x);
    |               ^^ help: change this to: `x`
 
 error: the borrowed expression implements the required traits
-  --> $DIR/needless_borrow.rs:457:13
+  --> $DIR/needless_borrow.rs:458:13
    |
 LL |         foo(&a);
    |             ^^ help: change this to: `a`
diff --git a/tests/ui/needless_range_loop.rs b/tests/ui/needless_range_loop.rs
index 1935ccb94bd..a16ef5a5bca 100644
--- a/tests/ui/needless_range_loop.rs
+++ b/tests/ui/needless_range_loop.rs
@@ -1,5 +1,9 @@
 #![warn(clippy::needless_range_loop)]
-#![allow(clippy::uninlined_format_args, clippy::useless_vec)]
+#![allow(
+    clippy::uninlined_format_args,
+    clippy::unnecessary_literal_unwrap,
+    clippy::useless_vec
+)]
 
 static STATIC: [usize; 4] = [0, 1, 8, 16];
 const CONST: [usize; 4] = [0, 1, 8, 16];
diff --git a/tests/ui/needless_range_loop.stderr b/tests/ui/needless_range_loop.stderr
index cffa19bec3a..8ca6b880cea 100644
--- a/tests/ui/needless_range_loop.stderr
+++ b/tests/ui/needless_range_loop.stderr
@@ -1,5 +1,5 @@
 error: the loop variable `i` is only used to index `vec`
-  --> $DIR/needless_range_loop.rs:11:14
+  --> $DIR/needless_range_loop.rs:15:14
    |
 LL |     for i in 0..vec.len() {
    |              ^^^^^^^^^^^^
@@ -11,7 +11,7 @@ LL |     for <item> in &vec {
    |         ~~~~~~    ~~~~
 
 error: the loop variable `i` is only used to index `vec`
-  --> $DIR/needless_range_loop.rs:20:14
+  --> $DIR/needless_range_loop.rs:24:14
    |
 LL |     for i in 0..vec.len() {
    |              ^^^^^^^^^^^^
@@ -22,7 +22,7 @@ LL |     for <item> in &vec {
    |         ~~~~~~    ~~~~
 
 error: the loop variable `j` is only used to index `STATIC`
-  --> $DIR/needless_range_loop.rs:25:14
+  --> $DIR/needless_range_loop.rs:29:14
    |
 LL |     for j in 0..4 {
    |              ^^^^
@@ -33,7 +33,7 @@ LL |     for <item> in &STATIC {
    |         ~~~~~~    ~~~~~~~
 
 error: the loop variable `j` is only used to index `CONST`
-  --> $DIR/needless_range_loop.rs:29:14
+  --> $DIR/needless_range_loop.rs:33:14
    |
 LL |     for j in 0..4 {
    |              ^^^^
@@ -44,7 +44,7 @@ LL |     for <item> in &CONST {
    |         ~~~~~~    ~~~~~~
 
 error: the loop variable `i` is used to index `vec`
-  --> $DIR/needless_range_loop.rs:33:14
+  --> $DIR/needless_range_loop.rs:37:14
    |
 LL |     for i in 0..vec.len() {
    |              ^^^^^^^^^^^^
@@ -55,7 +55,7 @@ LL |     for (i, <item>) in vec.iter().enumerate() {
    |         ~~~~~~~~~~~    ~~~~~~~~~~~~~~~~~~~~~~
 
 error: the loop variable `i` is only used to index `vec2`
-  --> $DIR/needless_range_loop.rs:41:14
+  --> $DIR/needless_range_loop.rs:45:14
    |
 LL |     for i in 0..vec.len() {
    |              ^^^^^^^^^^^^
@@ -66,7 +66,7 @@ LL |     for <item> in vec2.iter().take(vec.len()) {
    |         ~~~~~~    ~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 error: the loop variable `i` is only used to index `vec`
-  --> $DIR/needless_range_loop.rs:45:14
+  --> $DIR/needless_range_loop.rs:49:14
    |
 LL |     for i in 5..vec.len() {
    |              ^^^^^^^^^^^^
@@ -77,7 +77,7 @@ LL |     for <item> in vec.iter().skip(5) {
    |         ~~~~~~    ~~~~~~~~~~~~~~~~~~
 
 error: the loop variable `i` is only used to index `vec`
-  --> $DIR/needless_range_loop.rs:49:14
+  --> $DIR/needless_range_loop.rs:53:14
    |
 LL |     for i in 0..MAX_LEN {
    |              ^^^^^^^^^^
@@ -88,7 +88,7 @@ LL |     for <item> in vec.iter().take(MAX_LEN) {
    |         ~~~~~~    ~~~~~~~~~~~~~~~~~~~~~~~~
 
 error: the loop variable `i` is only used to index `vec`
-  --> $DIR/needless_range_loop.rs:53:14
+  --> $DIR/needless_range_loop.rs:57:14
    |
 LL |     for i in 0..=MAX_LEN {
    |              ^^^^^^^^^^^
@@ -99,7 +99,7 @@ LL |     for <item> in vec.iter().take(MAX_LEN + 1) {
    |         ~~~~~~    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 error: the loop variable `i` is only used to index `vec`
-  --> $DIR/needless_range_loop.rs:57:14
+  --> $DIR/needless_range_loop.rs:61:14
    |
 LL |     for i in 5..10 {
    |              ^^^^^
@@ -110,7 +110,7 @@ LL |     for <item> in vec.iter().take(10).skip(5) {
    |         ~~~~~~    ~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 error: the loop variable `i` is only used to index `vec`
-  --> $DIR/needless_range_loop.rs:61:14
+  --> $DIR/needless_range_loop.rs:65:14
    |
 LL |     for i in 5..=10 {
    |              ^^^^^^
@@ -121,7 +121,7 @@ LL |     for <item> in vec.iter().take(10 + 1).skip(5) {
    |         ~~~~~~    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 error: the loop variable `i` is used to index `vec`
-  --> $DIR/needless_range_loop.rs:65:14
+  --> $DIR/needless_range_loop.rs:69:14
    |
 LL |     for i in 5..vec.len() {
    |              ^^^^^^^^^^^^
@@ -132,7 +132,7 @@ LL |     for (i, <item>) in vec.iter().enumerate().skip(5) {
    |         ~~~~~~~~~~~    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 error: the loop variable `i` is used to index `vec`
-  --> $DIR/needless_range_loop.rs:69:14
+  --> $DIR/needless_range_loop.rs:73:14
    |
 LL |     for i in 5..10 {
    |              ^^^^^
@@ -143,7 +143,7 @@ LL |     for (i, <item>) in vec.iter().enumerate().take(10).skip(5) {
    |         ~~~~~~~~~~~    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 error: the loop variable `i` is used to index `vec`
-  --> $DIR/needless_range_loop.rs:74:14
+  --> $DIR/needless_range_loop.rs:78:14
    |
 LL |     for i in 0..vec.len() {
    |              ^^^^^^^^^^^^
diff --git a/tests/ui/ok_expect.rs b/tests/ui/ok_expect.rs
index ff68d38c73b..2047ee689d9 100644
--- a/tests/ui/ok_expect.rs
+++ b/tests/ui/ok_expect.rs
@@ -1,3 +1,5 @@
+#![allow(clippy::unnecessary_literal_unwrap)]
+
 use std::io;
 
 struct MyError(()); // doesn't implement Debug
diff --git a/tests/ui/ok_expect.stderr b/tests/ui/ok_expect.stderr
index 6c40adbb53d..ab9df26ebc3 100644
--- a/tests/ui/ok_expect.stderr
+++ b/tests/ui/ok_expect.stderr
@@ -1,5 +1,5 @@
 error: called `ok().expect()` on a `Result` value
-  --> $DIR/ok_expect.rs:14:5
+  --> $DIR/ok_expect.rs:16:5
    |
 LL |     res.ok().expect("disaster!");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -8,7 +8,7 @@ LL |     res.ok().expect("disaster!");
    = note: `-D clippy::ok-expect` implied by `-D warnings`
 
 error: called `ok().expect()` on a `Result` value
-  --> $DIR/ok_expect.rs:20:5
+  --> $DIR/ok_expect.rs:22:5
    |
 LL |     res3.ok().expect("whoof");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -16,7 +16,7 @@ LL |     res3.ok().expect("whoof");
    = help: you can call `expect()` directly on the `Result`
 
 error: called `ok().expect()` on a `Result` value
-  --> $DIR/ok_expect.rs:22:5
+  --> $DIR/ok_expect.rs:24:5
    |
 LL |     res4.ok().expect("argh");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -24,7 +24,7 @@ LL |     res4.ok().expect("argh");
    = help: you can call `expect()` directly on the `Result`
 
 error: called `ok().expect()` on a `Result` value
-  --> $DIR/ok_expect.rs:24:5
+  --> $DIR/ok_expect.rs:26:5
    |
 LL |     res5.ok().expect("oops");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -32,7 +32,7 @@ LL |     res5.ok().expect("oops");
    = help: you can call `expect()` directly on the `Result`
 
 error: called `ok().expect()` on a `Result` value
-  --> $DIR/ok_expect.rs:26:5
+  --> $DIR/ok_expect.rs:28:5
    |
 LL |     res6.ok().expect("meh");
    |     ^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/or_fun_call.fixed b/tests/ui/or_fun_call.fixed
index 08a536a2844..703debb7a26 100644
--- a/tests/ui/or_fun_call.fixed
+++ b/tests/ui/or_fun_call.fixed
@@ -5,6 +5,7 @@
     clippy::borrow_as_ptr,
     clippy::uninlined_format_args,
     clippy::unnecessary_wraps,
+    clippy::unnecessary_literal_unwrap,
     clippy::useless_vec
 )]
 
diff --git a/tests/ui/or_fun_call.rs b/tests/ui/or_fun_call.rs
index 83ba68382ef..bb86fe0d45f 100644
--- a/tests/ui/or_fun_call.rs
+++ b/tests/ui/or_fun_call.rs
@@ -5,6 +5,7 @@
     clippy::borrow_as_ptr,
     clippy::uninlined_format_args,
     clippy::unnecessary_wraps,
+    clippy::unnecessary_literal_unwrap,
     clippy::useless_vec
 )]
 
diff --git a/tests/ui/or_fun_call.stderr b/tests/ui/or_fun_call.stderr
index ec87674b100..0b5c686bec0 100644
--- a/tests/ui/or_fun_call.stderr
+++ b/tests/ui/or_fun_call.stderr
@@ -1,5 +1,5 @@
 error: use of `unwrap_or` followed by a function call
-  --> $DIR/or_fun_call.rs:53:22
+  --> $DIR/or_fun_call.rs:54:22
    |
 LL |     with_constructor.unwrap_or(make());
    |                      ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(make)`
@@ -7,163 +7,163 @@ LL |     with_constructor.unwrap_or(make());
    = note: `-D clippy::or-fun-call` implied by `-D warnings`
 
 error: use of `unwrap_or` followed by a call to `new`
-  --> $DIR/or_fun_call.rs:56:14
+  --> $DIR/or_fun_call.rs:57:14
    |
 LL |     with_new.unwrap_or(Vec::new());
    |              ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_default()`
 
 error: use of `unwrap_or` followed by a function call
-  --> $DIR/or_fun_call.rs:59:21
+  --> $DIR/or_fun_call.rs:60:21
    |
 LL |     with_const_args.unwrap_or(Vec::with_capacity(12));
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| Vec::with_capacity(12))`
 
 error: use of `unwrap_or` followed by a function call
-  --> $DIR/or_fun_call.rs:62:14
+  --> $DIR/or_fun_call.rs:63:14
    |
 LL |     with_err.unwrap_or(make());
    |              ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| make())`
 
 error: use of `unwrap_or` followed by a function call
-  --> $DIR/or_fun_call.rs:65:19
+  --> $DIR/or_fun_call.rs:66:19
    |
 LL |     with_err_args.unwrap_or(Vec::with_capacity(12));
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| Vec::with_capacity(12))`
 
 error: use of `unwrap_or` followed by a call to `default`
-  --> $DIR/or_fun_call.rs:68:24
+  --> $DIR/or_fun_call.rs:69:24
    |
 LL |     with_default_trait.unwrap_or(Default::default());
    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_default()`
 
 error: use of `unwrap_or` followed by a call to `default`
-  --> $DIR/or_fun_call.rs:71:23
+  --> $DIR/or_fun_call.rs:72:23
    |
 LL |     with_default_type.unwrap_or(u64::default());
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_default()`
 
 error: use of `unwrap_or` followed by a function call
-  --> $DIR/or_fun_call.rs:74:18
+  --> $DIR/or_fun_call.rs:75:18
    |
 LL |     self_default.unwrap_or(<FakeDefault>::default());
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(<FakeDefault>::default)`
 
 error: use of `unwrap_or` followed by a call to `default`
-  --> $DIR/or_fun_call.rs:77:18
+  --> $DIR/or_fun_call.rs:78:18
    |
 LL |     real_default.unwrap_or(<FakeDefault as Default>::default());
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_default()`
 
 error: use of `unwrap_or` followed by a call to `new`
-  --> $DIR/or_fun_call.rs:80:14
+  --> $DIR/or_fun_call.rs:81:14
    |
 LL |     with_vec.unwrap_or(vec![]);
    |              ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_default()`
 
 error: use of `unwrap_or` followed by a function call
-  --> $DIR/or_fun_call.rs:83:21
+  --> $DIR/or_fun_call.rs:84:21
    |
 LL |     without_default.unwrap_or(Foo::new());
    |                     ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(Foo::new)`
 
 error: use of `or_insert` followed by a call to `new`
-  --> $DIR/or_fun_call.rs:86:19
+  --> $DIR/or_fun_call.rs:87:19
    |
 LL |     map.entry(42).or_insert(String::new());
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_default()`
 
 error: use of `or_insert` followed by a call to `new`
-  --> $DIR/or_fun_call.rs:89:23
+  --> $DIR/or_fun_call.rs:90:23
    |
 LL |     map_vec.entry(42).or_insert(vec![]);
    |                       ^^^^^^^^^^^^^^^^^ help: try this: `or_default()`
 
 error: use of `or_insert` followed by a call to `new`
-  --> $DIR/or_fun_call.rs:92:21
+  --> $DIR/or_fun_call.rs:93:21
    |
 LL |     btree.entry(42).or_insert(String::new());
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_default()`
 
 error: use of `or_insert` followed by a call to `new`
-  --> $DIR/or_fun_call.rs:95:25
+  --> $DIR/or_fun_call.rs:96:25
    |
 LL |     btree_vec.entry(42).or_insert(vec![]);
    |                         ^^^^^^^^^^^^^^^^^ help: try this: `or_default()`
 
 error: use of `unwrap_or` followed by a call to `new`
-  --> $DIR/or_fun_call.rs:98:21
+  --> $DIR/or_fun_call.rs:99:21
    |
 LL |     let _ = stringy.unwrap_or(String::new());
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_default()`
 
 error: use of `unwrap_or` followed by a function call
-  --> $DIR/or_fun_call.rs:106:21
+  --> $DIR/or_fun_call.rs:107:21
    |
 LL |     let _ = Some(1).unwrap_or(map[&1]);
    |                     ^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| map[&1])`
 
 error: use of `unwrap_or` followed by a function call
-  --> $DIR/or_fun_call.rs:108:21
+  --> $DIR/or_fun_call.rs:109:21
    |
 LL |     let _ = Some(1).unwrap_or(map[&1]);
    |                     ^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| map[&1])`
 
 error: use of `or` followed by a function call
-  --> $DIR/or_fun_call.rs:132:35
+  --> $DIR/or_fun_call.rs:133:35
    |
 LL |     let _ = Some("a".to_string()).or(Some("b".to_string()));
    |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_else(|| Some("b".to_string()))`
 
 error: use of `unwrap_or` followed by a function call
-  --> $DIR/or_fun_call.rs:171:14
+  --> $DIR/or_fun_call.rs:172:14
    |
 LL |         None.unwrap_or(ptr_to_ref(s));
    |              ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| ptr_to_ref(s))`
 
 error: use of `unwrap_or` followed by a function call
-  --> $DIR/or_fun_call.rs:177:14
+  --> $DIR/or_fun_call.rs:178:14
    |
 LL |         None.unwrap_or(unsafe { ptr_to_ref(s) });
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| unsafe { ptr_to_ref(s) })`
 
 error: use of `unwrap_or` followed by a function call
-  --> $DIR/or_fun_call.rs:179:14
+  --> $DIR/or_fun_call.rs:180:14
    |
 LL |         None.unwrap_or( unsafe { ptr_to_ref(s) }    );
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| unsafe { ptr_to_ref(s) })`
 
 error: use of `unwrap_or` followed by a call to `new`
-  --> $DIR/or_fun_call.rs:193:14
+  --> $DIR/or_fun_call.rs:194:14
    |
 LL |             .unwrap_or(String::new());
    |              ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_default()`
 
 error: use of `unwrap_or` followed by a call to `new`
-  --> $DIR/or_fun_call.rs:206:14
+  --> $DIR/or_fun_call.rs:207:14
    |
 LL |             .unwrap_or(String::new());
    |              ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_default()`
 
 error: use of `unwrap_or` followed by a call to `new`
-  --> $DIR/or_fun_call.rs:218:14
+  --> $DIR/or_fun_call.rs:219:14
    |
 LL |             .unwrap_or(String::new());
    |              ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_default()`
 
 error: use of `unwrap_or` followed by a call to `new`
-  --> $DIR/or_fun_call.rs:229:10
+  --> $DIR/or_fun_call.rs:230:10
    |
 LL |         .unwrap_or(String::new());
    |          ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_default()`
 
 error: use of `map_or` followed by a function call
-  --> $DIR/or_fun_call.rs:254:25
+  --> $DIR/or_fun_call.rs:255:25
    |
 LL |         let _ = Some(4).map_or(g(), |v| v);
    |                         ^^^^^^^^^^^^^^^^^^ help: try this: `map_or_else(g, |v| v)`
 
 error: use of `map_or` followed by a function call
-  --> $DIR/or_fun_call.rs:255:25
+  --> $DIR/or_fun_call.rs:256:25
    |
 LL |         let _ = Some(4).map_or(g(), f);
    |                         ^^^^^^^^^^^^^^ help: try this: `map_or_else(g, f)`
diff --git a/tests/ui/or_then_unwrap.fixed b/tests/ui/or_then_unwrap.fixed
index 40badac4424..773dfc3c5d1 100644
--- a/tests/ui/or_then_unwrap.fixed
+++ b/tests/ui/or_then_unwrap.fixed
@@ -1,7 +1,7 @@
 //@run-rustfix
 
 #![warn(clippy::or_then_unwrap)]
-#![allow(clippy::map_identity, clippy::let_unit_value)]
+#![allow(clippy::map_identity, clippy::let_unit_value, clippy::unnecessary_literal_unwrap)]
 
 struct SomeStruct;
 impl SomeStruct {
diff --git a/tests/ui/or_then_unwrap.rs b/tests/ui/or_then_unwrap.rs
index 76c9942fe6c..5867e014878 100644
--- a/tests/ui/or_then_unwrap.rs
+++ b/tests/ui/or_then_unwrap.rs
@@ -1,7 +1,7 @@
 //@run-rustfix
 
 #![warn(clippy::or_then_unwrap)]
-#![allow(clippy::map_identity, clippy::let_unit_value)]
+#![allow(clippy::map_identity, clippy::let_unit_value, clippy::unnecessary_literal_unwrap)]
 
 struct SomeStruct;
 impl SomeStruct {
diff --git a/tests/ui/redundant_clone.fixed b/tests/ui/redundant_clone.fixed
index cb9583aa6ee..5037c08ebd5 100644
--- a/tests/ui/redundant_clone.fixed
+++ b/tests/ui/redundant_clone.fixed
@@ -2,7 +2,12 @@
 // rustfix-only-machine-applicable
 #![feature(lint_reasons)]
 #![warn(clippy::redundant_clone)]
-#![allow(clippy::drop_non_drop, clippy::implicit_clone, clippy::uninlined_format_args)]
+#![allow(
+    clippy::drop_non_drop,
+    clippy::implicit_clone,
+    clippy::uninlined_format_args,
+    clippy::unnecessary_literal_unwrap
+)]
 
 use std::ffi::OsString;
 use std::path::Path;
diff --git a/tests/ui/redundant_clone.rs b/tests/ui/redundant_clone.rs
index e5aeacbb56c..501898bf113 100644
--- a/tests/ui/redundant_clone.rs
+++ b/tests/ui/redundant_clone.rs
@@ -2,7 +2,12 @@
 // rustfix-only-machine-applicable
 #![feature(lint_reasons)]
 #![warn(clippy::redundant_clone)]
-#![allow(clippy::drop_non_drop, clippy::implicit_clone, clippy::uninlined_format_args)]
+#![allow(
+    clippy::drop_non_drop,
+    clippy::implicit_clone,
+    clippy::uninlined_format_args,
+    clippy::unnecessary_literal_unwrap
+)]
 
 use std::ffi::OsString;
 use std::path::Path;
diff --git a/tests/ui/redundant_clone.stderr b/tests/ui/redundant_clone.stderr
index bb5c602d63a..8660c0e1f6a 100644
--- a/tests/ui/redundant_clone.stderr
+++ b/tests/ui/redundant_clone.stderr
@@ -1,180 +1,180 @@
 error: redundant clone
-  --> $DIR/redundant_clone.rs:11:42
+  --> $DIR/redundant_clone.rs:16:42
    |
 LL |     let _s = ["lorem", "ipsum"].join(" ").to_string();
    |                                          ^^^^^^^^^^^^ help: remove this
    |
 note: this value is dropped without further use
-  --> $DIR/redundant_clone.rs:11:14
+  --> $DIR/redundant_clone.rs:16:14
    |
 LL |     let _s = ["lorem", "ipsum"].join(" ").to_string();
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: `-D clippy::redundant-clone` implied by `-D warnings`
 
 error: redundant clone
-  --> $DIR/redundant_clone.rs:14:15
+  --> $DIR/redundant_clone.rs:19:15
    |
 LL |     let _s = s.clone();
    |               ^^^^^^^^ help: remove this
    |
 note: this value is dropped without further use
-  --> $DIR/redundant_clone.rs:14:14
+  --> $DIR/redundant_clone.rs:19:14
    |
 LL |     let _s = s.clone();
    |              ^
 
 error: redundant clone
-  --> $DIR/redundant_clone.rs:17:15
+  --> $DIR/redundant_clone.rs:22:15
    |
 LL |     let _s = s.to_string();
    |               ^^^^^^^^^^^^ help: remove this
    |
 note: this value is dropped without further use
-  --> $DIR/redundant_clone.rs:17:14
+  --> $DIR/redundant_clone.rs:22:14
    |
 LL |     let _s = s.to_string();
    |              ^
 
 error: redundant clone
-  --> $DIR/redundant_clone.rs:20:15
+  --> $DIR/redundant_clone.rs:25:15
    |
 LL |     let _s = s.to_owned();
    |               ^^^^^^^^^^^ help: remove this
    |
 note: this value is dropped without further use
-  --> $DIR/redundant_clone.rs:20:14
+  --> $DIR/redundant_clone.rs:25:14
    |
 LL |     let _s = s.to_owned();
    |              ^
 
 error: redundant clone
-  --> $DIR/redundant_clone.rs:22:42
+  --> $DIR/redundant_clone.rs:27:42
    |
 LL |     let _s = Path::new("/a/b/").join("c").to_owned();
    |                                          ^^^^^^^^^^^ help: remove this
    |
 note: this value is dropped without further use
-  --> $DIR/redundant_clone.rs:22:14
+  --> $DIR/redundant_clone.rs:27:14
    |
 LL |     let _s = Path::new("/a/b/").join("c").to_owned();
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: redundant clone
-  --> $DIR/redundant_clone.rs:24:42
+  --> $DIR/redundant_clone.rs:29:42
    |
 LL |     let _s = Path::new("/a/b/").join("c").to_path_buf();
    |                                          ^^^^^^^^^^^^^^ help: remove this
    |
 note: this value is dropped without further use
-  --> $DIR/redundant_clone.rs:24:14
+  --> $DIR/redundant_clone.rs:29:14
    |
 LL |     let _s = Path::new("/a/b/").join("c").to_path_buf();
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: redundant clone
-  --> $DIR/redundant_clone.rs:26:29
+  --> $DIR/redundant_clone.rs:31:29
    |
 LL |     let _s = OsString::new().to_owned();
    |                             ^^^^^^^^^^^ help: remove this
    |
 note: this value is dropped without further use
-  --> $DIR/redundant_clone.rs:26:14
+  --> $DIR/redundant_clone.rs:31:14
    |
 LL |     let _s = OsString::new().to_owned();
    |              ^^^^^^^^^^^^^^^
 
 error: redundant clone
-  --> $DIR/redundant_clone.rs:28:29
+  --> $DIR/redundant_clone.rs:33:29
    |
 LL |     let _s = OsString::new().to_os_string();
    |                             ^^^^^^^^^^^^^^^ help: remove this
    |
 note: this value is dropped without further use
-  --> $DIR/redundant_clone.rs:28:14
+  --> $DIR/redundant_clone.rs:33:14
    |
 LL |     let _s = OsString::new().to_os_string();
    |              ^^^^^^^^^^^^^^^
 
 error: redundant clone
-  --> $DIR/redundant_clone.rs:39:19
+  --> $DIR/redundant_clone.rs:44:19
    |
 LL |     let _t = tup.0.clone();
    |                   ^^^^^^^^ help: remove this
    |
 note: this value is dropped without further use
-  --> $DIR/redundant_clone.rs:39:14
+  --> $DIR/redundant_clone.rs:44:14
    |
 LL |     let _t = tup.0.clone();
    |              ^^^^^
 
 error: redundant clone
-  --> $DIR/redundant_clone.rs:71:25
+  --> $DIR/redundant_clone.rs:76:25
    |
 LL |     if b { (a.clone(), a.clone()) } else { (Alpha, a) }
    |                         ^^^^^^^^ help: remove this
    |
 note: this value is dropped without further use
-  --> $DIR/redundant_clone.rs:71:24
+  --> $DIR/redundant_clone.rs:76:24
    |
 LL |     if b { (a.clone(), a.clone()) } else { (Alpha, a) }
    |                        ^
 
 error: redundant clone
-  --> $DIR/redundant_clone.rs:128:15
+  --> $DIR/redundant_clone.rs:133:15
    |
 LL |     let _s = s.clone();
    |               ^^^^^^^^ help: remove this
    |
 note: this value is dropped without further use
-  --> $DIR/redundant_clone.rs:128:14
+  --> $DIR/redundant_clone.rs:133:14
    |
 LL |     let _s = s.clone();
    |              ^
 
 error: redundant clone
-  --> $DIR/redundant_clone.rs:129:15
+  --> $DIR/redundant_clone.rs:134:15
    |
 LL |     let _t = t.clone();
    |               ^^^^^^^^ help: remove this
    |
 note: this value is dropped without further use
-  --> $DIR/redundant_clone.rs:129:14
+  --> $DIR/redundant_clone.rs:134:14
    |
 LL |     let _t = t.clone();
    |              ^
 
 error: redundant clone
-  --> $DIR/redundant_clone.rs:139:19
+  --> $DIR/redundant_clone.rs:144:19
    |
 LL |         let _f = f.clone();
    |                   ^^^^^^^^ help: remove this
    |
 note: this value is dropped without further use
-  --> $DIR/redundant_clone.rs:139:18
+  --> $DIR/redundant_clone.rs:144:18
    |
 LL |         let _f = f.clone();
    |                  ^
 
 error: redundant clone
-  --> $DIR/redundant_clone.rs:151:14
+  --> $DIR/redundant_clone.rs:156:14
    |
 LL |     let y = x.clone().join("matthias");
    |              ^^^^^^^^ help: remove this
    |
 note: cloned value is neither consumed nor mutated
-  --> $DIR/redundant_clone.rs:151:13
+  --> $DIR/redundant_clone.rs:156:13
    |
 LL |     let y = x.clone().join("matthias");
    |             ^^^^^^^^^
 
 error: redundant clone
-  --> $DIR/redundant_clone.rs:205:11
+  --> $DIR/redundant_clone.rs:210:11
    |
 LL |     foo(&x.clone(), move || {
    |           ^^^^^^^^ help: remove this
    |
 note: this value is dropped without further use
-  --> $DIR/redundant_clone.rs:205:10
+  --> $DIR/redundant_clone.rs:210:10
    |
 LL |     foo(&x.clone(), move || {
    |          ^
diff --git a/tests/ui/uninlined_format_args.fixed b/tests/ui/uninlined_format_args.fixed
index e25d123dd51..972e0356b62 100644
--- a/tests/ui/uninlined_format_args.fixed
+++ b/tests/ui/uninlined_format_args.fixed
@@ -2,7 +2,12 @@
 //@run-rustfix
 #![warn(clippy::uninlined_format_args)]
 #![allow(named_arguments_used_positionally, unused)]
-#![allow(clippy::eq_op, clippy::format_in_format_args, clippy::print_literal)]
+#![allow(
+    clippy::eq_op,
+    clippy::format_in_format_args,
+    clippy::print_literal,
+    clippy::unnecessary_literal_unwrap
+)]
 
 extern crate proc_macros;
 use proc_macros::with_span;
diff --git a/tests/ui/uninlined_format_args.rs b/tests/ui/uninlined_format_args.rs
index 6793ec24441..7614ffb38e6 100644
--- a/tests/ui/uninlined_format_args.rs
+++ b/tests/ui/uninlined_format_args.rs
@@ -2,7 +2,12 @@
 //@run-rustfix
 #![warn(clippy::uninlined_format_args)]
 #![allow(named_arguments_used_positionally, unused)]
-#![allow(clippy::eq_op, clippy::format_in_format_args, clippy::print_literal)]
+#![allow(
+    clippy::eq_op,
+    clippy::format_in_format_args,
+    clippy::print_literal,
+    clippy::unnecessary_literal_unwrap
+)]
 
 extern crate proc_macros;
 use proc_macros::with_span;
diff --git a/tests/ui/uninlined_format_args.stderr b/tests/ui/uninlined_format_args.stderr
index dc4af6ef42e..44ca61f008c 100644
--- a/tests/ui/uninlined_format_args.stderr
+++ b/tests/ui/uninlined_format_args.stderr
@@ -1,5 +1,5 @@
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:40:5
+  --> $DIR/uninlined_format_args.rs:45:5
    |
 LL |     println!("val='{}'", local_i32);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -12,7 +12,7 @@ LL +     println!("val='{local_i32}'");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:41:5
+  --> $DIR/uninlined_format_args.rs:46:5
    |
 LL |     println!("val='{   }'", local_i32); // 3 spaces
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -24,7 +24,7 @@ LL +     println!("val='{local_i32}'"); // 3 spaces
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:42:5
+  --> $DIR/uninlined_format_args.rs:47:5
    |
 LL |     println!("val='{    }'", local_i32); // tab
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -36,7 +36,7 @@ LL +     println!("val='{local_i32}'"); // tab
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:43:5
+  --> $DIR/uninlined_format_args.rs:48:5
    |
 LL |     println!("val='{     }'", local_i32); // space+tab
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -48,7 +48,7 @@ LL +     println!("val='{local_i32}'"); // space+tab
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:44:5
+  --> $DIR/uninlined_format_args.rs:49:5
    |
 LL |     println!("val='{     }'", local_i32); // tab+space
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -60,7 +60,7 @@ LL +     println!("val='{local_i32}'"); // tab+space
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:45:5
+  --> $DIR/uninlined_format_args.rs:50:5
    |
 LL | /     println!(
 LL | |         "val='{
@@ -70,7 +70,7 @@ LL | |     );
    | |_____^
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:50:5
+  --> $DIR/uninlined_format_args.rs:55:5
    |
 LL |     println!("{}", local_i32);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -82,7 +82,7 @@ LL +     println!("{local_i32}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:51:5
+  --> $DIR/uninlined_format_args.rs:56:5
    |
 LL |     println!("{}", fn_arg);
    |     ^^^^^^^^^^^^^^^^^^^^^^
@@ -94,7 +94,7 @@ LL +     println!("{fn_arg}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:52:5
+  --> $DIR/uninlined_format_args.rs:57:5
    |
 LL |     println!("{:?}", local_i32);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -106,7 +106,7 @@ LL +     println!("{local_i32:?}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:53:5
+  --> $DIR/uninlined_format_args.rs:58:5
    |
 LL |     println!("{:#?}", local_i32);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -118,7 +118,7 @@ LL +     println!("{local_i32:#?}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:54:5
+  --> $DIR/uninlined_format_args.rs:59:5
    |
 LL |     println!("{:4}", local_i32);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -130,7 +130,7 @@ LL +     println!("{local_i32:4}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:55:5
+  --> $DIR/uninlined_format_args.rs:60:5
    |
 LL |     println!("{:04}", local_i32);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -142,7 +142,7 @@ LL +     println!("{local_i32:04}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:56:5
+  --> $DIR/uninlined_format_args.rs:61:5
    |
 LL |     println!("{:<3}", local_i32);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -154,7 +154,7 @@ LL +     println!("{local_i32:<3}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:57:5
+  --> $DIR/uninlined_format_args.rs:62:5
    |
 LL |     println!("{:#010x}", local_i32);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -166,7 +166,7 @@ LL +     println!("{local_i32:#010x}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:58:5
+  --> $DIR/uninlined_format_args.rs:63:5
    |
 LL |     println!("{:.1}", local_f64);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -178,7 +178,7 @@ LL +     println!("{local_f64:.1}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:62:5
+  --> $DIR/uninlined_format_args.rs:67:5
    |
 LL |     println!("{} {}", local_i32, local_f64);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -190,7 +190,7 @@ LL +     println!("{local_i32} {local_f64}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:64:5
+  --> $DIR/uninlined_format_args.rs:69:5
    |
 LL |     println!("{}", val);
    |     ^^^^^^^^^^^^^^^^^^^
@@ -202,7 +202,7 @@ LL +     println!("{val}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:65:5
+  --> $DIR/uninlined_format_args.rs:70:5
    |
 LL |     println!("{}", v = val);
    |     ^^^^^^^^^^^^^^^^^^^^^^^
@@ -214,7 +214,7 @@ LL +     println!("{val}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:67:5
+  --> $DIR/uninlined_format_args.rs:72:5
    |
 LL |     println!("val='{/t }'", local_i32);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -226,7 +226,7 @@ LL +     println!("val='{local_i32}'");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:68:5
+  --> $DIR/uninlined_format_args.rs:73:5
    |
 LL |     println!("val='{/n }'", local_i32);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -238,7 +238,7 @@ LL +     println!("val='{local_i32}'");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:69:5
+  --> $DIR/uninlined_format_args.rs:74:5
    |
 LL |     println!("val='{local_i32}'", local_i32 = local_i32);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -250,7 +250,7 @@ LL +     println!("val='{local_i32}'");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:70:5
+  --> $DIR/uninlined_format_args.rs:75:5
    |
 LL |     println!("val='{local_i32}'", local_i32 = fn_arg);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -262,7 +262,7 @@ LL +     println!("val='{fn_arg}'");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:71:5
+  --> $DIR/uninlined_format_args.rs:76:5
    |
 LL |     println!("{0}", local_i32);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -274,7 +274,7 @@ LL +     println!("{local_i32}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:72:5
+  --> $DIR/uninlined_format_args.rs:77:5
    |
 LL |     println!("{0:?}", local_i32);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -286,7 +286,7 @@ LL +     println!("{local_i32:?}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:73:5
+  --> $DIR/uninlined_format_args.rs:78:5
    |
 LL |     println!("{0:#?}", local_i32);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -298,7 +298,7 @@ LL +     println!("{local_i32:#?}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:74:5
+  --> $DIR/uninlined_format_args.rs:79:5
    |
 LL |     println!("{0:04}", local_i32);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -310,7 +310,7 @@ LL +     println!("{local_i32:04}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:75:5
+  --> $DIR/uninlined_format_args.rs:80:5
    |
 LL |     println!("{0:<3}", local_i32);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -322,7 +322,7 @@ LL +     println!("{local_i32:<3}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:76:5
+  --> $DIR/uninlined_format_args.rs:81:5
    |
 LL |     println!("{0:#010x}", local_i32);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -334,7 +334,7 @@ LL +     println!("{local_i32:#010x}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:77:5
+  --> $DIR/uninlined_format_args.rs:82:5
    |
 LL |     println!("{0:.1}", local_f64);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -346,7 +346,7 @@ LL +     println!("{local_f64:.1}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:78:5
+  --> $DIR/uninlined_format_args.rs:83:5
    |
 LL |     println!("{0} {0}", local_i32);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -358,7 +358,7 @@ LL +     println!("{local_i32} {local_i32}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:79:5
+  --> $DIR/uninlined_format_args.rs:84:5
    |
 LL |     println!("{1} {} {0} {}", local_i32, local_f64);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -370,7 +370,7 @@ LL +     println!("{local_f64} {local_i32} {local_i32} {local_f64}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:80:5
+  --> $DIR/uninlined_format_args.rs:85:5
    |
 LL |     println!("{0} {1}", local_i32, local_f64);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -382,7 +382,7 @@ LL +     println!("{local_i32} {local_f64}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:81:5
+  --> $DIR/uninlined_format_args.rs:86:5
    |
 LL |     println!("{1} {0}", local_i32, local_f64);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -394,7 +394,7 @@ LL +     println!("{local_f64} {local_i32}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:82:5
+  --> $DIR/uninlined_format_args.rs:87:5
    |
 LL |     println!("{1} {0} {1} {0}", local_i32, local_f64);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -406,7 +406,7 @@ LL +     println!("{local_f64} {local_i32} {local_f64} {local_i32}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:84:5
+  --> $DIR/uninlined_format_args.rs:89:5
    |
 LL |     println!("{v}", v = local_i32);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -418,7 +418,7 @@ LL +     println!("{local_i32}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:85:5
+  --> $DIR/uninlined_format_args.rs:90:5
    |
 LL |     println!("{local_i32:0$}", width);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -430,7 +430,7 @@ LL +     println!("{local_i32:width$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:86:5
+  --> $DIR/uninlined_format_args.rs:91:5
    |
 LL |     println!("{local_i32:w$}", w = width);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -442,7 +442,7 @@ LL +     println!("{local_i32:width$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:87:5
+  --> $DIR/uninlined_format_args.rs:92:5
    |
 LL |     println!("{local_i32:.0$}", prec);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -454,7 +454,7 @@ LL +     println!("{local_i32:.prec$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:88:5
+  --> $DIR/uninlined_format_args.rs:93:5
    |
 LL |     println!("{local_i32:.p$}", p = prec);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -466,7 +466,7 @@ LL +     println!("{local_i32:.prec$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:89:5
+  --> $DIR/uninlined_format_args.rs:94:5
    |
 LL |     println!("{:0$}", v = val);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -478,7 +478,7 @@ LL +     println!("{val:val$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:90:5
+  --> $DIR/uninlined_format_args.rs:95:5
    |
 LL |     println!("{0:0$}", v = val);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -490,7 +490,7 @@ LL +     println!("{val:val$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:91:5
+  --> $DIR/uninlined_format_args.rs:96:5
    |
 LL |     println!("{:0$.0$}", v = val);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -502,7 +502,7 @@ LL +     println!("{val:val$.val$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:92:5
+  --> $DIR/uninlined_format_args.rs:97:5
    |
 LL |     println!("{0:0$.0$}", v = val);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -514,7 +514,7 @@ LL +     println!("{val:val$.val$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:93:5
+  --> $DIR/uninlined_format_args.rs:98:5
    |
 LL |     println!("{0:0$.v$}", v = val);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -526,7 +526,7 @@ LL +     println!("{val:val$.val$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:94:5
+  --> $DIR/uninlined_format_args.rs:99:5
    |
 LL |     println!("{0:v$.0$}", v = val);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -538,7 +538,7 @@ LL +     println!("{val:val$.val$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:95:5
+  --> $DIR/uninlined_format_args.rs:100:5
    |
 LL |     println!("{v:0$.0$}", v = val);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -550,7 +550,7 @@ LL +     println!("{val:val$.val$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:96:5
+  --> $DIR/uninlined_format_args.rs:101:5
    |
 LL |     println!("{v:v$.0$}", v = val);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -562,7 +562,7 @@ LL +     println!("{val:val$.val$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:97:5
+  --> $DIR/uninlined_format_args.rs:102:5
    |
 LL |     println!("{v:0$.v$}", v = val);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -574,7 +574,7 @@ LL +     println!("{val:val$.val$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:98:5
+  --> $DIR/uninlined_format_args.rs:103:5
    |
 LL |     println!("{v:v$.v$}", v = val);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -586,7 +586,7 @@ LL +     println!("{val:val$.val$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:99:5
+  --> $DIR/uninlined_format_args.rs:104:5
    |
 LL |     println!("{:0$}", width);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -598,7 +598,7 @@ LL +     println!("{width:width$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:100:5
+  --> $DIR/uninlined_format_args.rs:105:5
    |
 LL |     println!("{:1$}", local_i32, width);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -610,7 +610,7 @@ LL +     println!("{local_i32:width$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:101:5
+  --> $DIR/uninlined_format_args.rs:106:5
    |
 LL |     println!("{:w$}", w = width);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -622,7 +622,7 @@ LL +     println!("{width:width$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:102:5
+  --> $DIR/uninlined_format_args.rs:107:5
    |
 LL |     println!("{:w$}", local_i32, w = width);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -634,7 +634,7 @@ LL +     println!("{local_i32:width$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:103:5
+  --> $DIR/uninlined_format_args.rs:108:5
    |
 LL |     println!("{:.0$}", prec);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -646,7 +646,7 @@ LL +     println!("{prec:.prec$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:104:5
+  --> $DIR/uninlined_format_args.rs:109:5
    |
 LL |     println!("{:.1$}", local_i32, prec);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -658,7 +658,7 @@ LL +     println!("{local_i32:.prec$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:105:5
+  --> $DIR/uninlined_format_args.rs:110:5
    |
 LL |     println!("{:.p$}", p = prec);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -670,7 +670,7 @@ LL +     println!("{prec:.prec$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:106:5
+  --> $DIR/uninlined_format_args.rs:111:5
    |
 LL |     println!("{:.p$}", local_i32, p = prec);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -682,7 +682,7 @@ LL +     println!("{local_i32:.prec$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:107:5
+  --> $DIR/uninlined_format_args.rs:112:5
    |
 LL |     println!("{:0$.1$}", width, prec);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -694,7 +694,7 @@ LL +     println!("{width:width$.prec$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:108:5
+  --> $DIR/uninlined_format_args.rs:113:5
    |
 LL |     println!("{:0$.w$}", width, w = prec);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -706,7 +706,7 @@ LL +     println!("{width:width$.prec$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:109:5
+  --> $DIR/uninlined_format_args.rs:114:5
    |
 LL |     println!("{:1$.2$}", local_f64, width, prec);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -718,7 +718,7 @@ LL +     println!("{local_f64:width$.prec$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:110:5
+  --> $DIR/uninlined_format_args.rs:115:5
    |
 LL |     println!("{:1$.2$} {0} {1} {2}", local_f64, width, prec);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -730,7 +730,7 @@ LL +     println!("{local_f64:width$.prec$} {local_f64} {width} {prec}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:111:5
+  --> $DIR/uninlined_format_args.rs:116:5
    |
 LL | /     println!(
 LL | |         "{0:1$.2$} {0:2$.1$} {1:0$.2$} {1:2$.0$} {2:0$.1$} {2:1$.0$}",
@@ -739,7 +739,7 @@ LL | |     );
    | |_____^
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:122:5
+  --> $DIR/uninlined_format_args.rs:127:5
    |
 LL |     println!("Width = {}, value with width = {:0$}", local_i32, local_f64);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -751,7 +751,7 @@ LL +     println!("Width = {local_i32}, value with width = {local_f64:local_i32$
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:123:5
+  --> $DIR/uninlined_format_args.rs:128:5
    |
 LL |     println!("{:w$.p$}", local_i32, w = width, p = prec);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -763,7 +763,7 @@ LL +     println!("{local_i32:width$.prec$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:124:5
+  --> $DIR/uninlined_format_args.rs:129:5
    |
 LL |     println!("{:w$.p$}", w = width, p = prec);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -775,7 +775,7 @@ LL +     println!("{width:width$.prec$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:143:5
+  --> $DIR/uninlined_format_args.rs:148:5
    |
 LL | /     println!(
 LL | |         "{}",
@@ -785,7 +785,7 @@ LL | |     );
    | |_____^
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:148:5
+  --> $DIR/uninlined_format_args.rs:153:5
    |
 LL |     println!("{}", /* comment with a comma , in it */ val);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -797,7 +797,7 @@ LL +     println!("{val}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:154:9
+  --> $DIR/uninlined_format_args.rs:159:9
    |
 LL |         panic!("p1 {}", local_i32);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -809,7 +809,7 @@ LL +         panic!("p1 {local_i32}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:157:9
+  --> $DIR/uninlined_format_args.rs:162:9
    |
 LL |         panic!("p2 {0}", local_i32);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -821,7 +821,7 @@ LL +         panic!("p2 {local_i32}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:160:9
+  --> $DIR/uninlined_format_args.rs:165:9
    |
 LL |         panic!("p3 {local_i32}", local_i32 = local_i32);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -833,7 +833,7 @@ LL +         panic!("p3 {local_i32}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:180:5
+  --> $DIR/uninlined_format_args.rs:185:5
    |
 LL |     println!("expand='{}'", local_i32);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/unnecessary_lazy_eval.fixed b/tests/ui/unnecessary_lazy_eval.fixed
index 565bd96cf30..75a42809ad2 100644
--- a/tests/ui/unnecessary_lazy_eval.fixed
+++ b/tests/ui/unnecessary_lazy_eval.fixed
@@ -5,6 +5,7 @@
 #![allow(clippy::bind_instead_of_map)]
 #![allow(clippy::map_identity)]
 #![allow(clippy::needless_borrow)]
+#![allow(clippy::unnecessary_literal_unwrap)]
 
 use std::ops::Deref;
 
diff --git a/tests/ui/unnecessary_lazy_eval.rs b/tests/ui/unnecessary_lazy_eval.rs
index 3627076b2af..3777b9c25c2 100644
--- a/tests/ui/unnecessary_lazy_eval.rs
+++ b/tests/ui/unnecessary_lazy_eval.rs
@@ -5,6 +5,7 @@
 #![allow(clippy::bind_instead_of_map)]
 #![allow(clippy::map_identity)]
 #![allow(clippy::needless_borrow)]
+#![allow(clippy::unnecessary_literal_unwrap)]
 
 use std::ops::Deref;
 
diff --git a/tests/ui/unnecessary_lazy_eval.stderr b/tests/ui/unnecessary_lazy_eval.stderr
index 2850a632fc7..458eed1f359 100644
--- a/tests/ui/unnecessary_lazy_eval.stderr
+++ b/tests/ui/unnecessary_lazy_eval.stderr
@@ -1,5 +1,5 @@
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:68:13
+  --> $DIR/unnecessary_lazy_eval.rs:69:13
    |
 LL |     let _ = opt.unwrap_or_else(|| 2);
    |             ^^^^--------------------
@@ -9,7 +9,7 @@ LL |     let _ = opt.unwrap_or_else(|| 2);
    = note: `-D clippy::unnecessary-lazy-evaluations` implied by `-D warnings`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:69:13
+  --> $DIR/unnecessary_lazy_eval.rs:70:13
    |
 LL |     let _ = opt.unwrap_or_else(|| astronomers_pi);
    |             ^^^^---------------------------------
@@ -17,7 +17,7 @@ LL |     let _ = opt.unwrap_or_else(|| astronomers_pi);
    |                 help: use `unwrap_or(..)` instead: `unwrap_or(astronomers_pi)`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:70:13
+  --> $DIR/unnecessary_lazy_eval.rs:71:13
    |
 LL |     let _ = opt.unwrap_or_else(|| ext_str.some_field);
    |             ^^^^-------------------------------------
@@ -25,7 +25,7 @@ LL |     let _ = opt.unwrap_or_else(|| ext_str.some_field);
    |                 help: use `unwrap_or(..)` instead: `unwrap_or(ext_str.some_field)`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:72:13
+  --> $DIR/unnecessary_lazy_eval.rs:73:13
    |
 LL |     let _ = opt.and_then(|_| ext_opt);
    |             ^^^^---------------------
@@ -33,7 +33,7 @@ LL |     let _ = opt.and_then(|_| ext_opt);
    |                 help: use `and(..)` instead: `and(ext_opt)`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:73:13
+  --> $DIR/unnecessary_lazy_eval.rs:74:13
    |
 LL |     let _ = opt.or_else(|| ext_opt);
    |             ^^^^-------------------
@@ -41,7 +41,7 @@ LL |     let _ = opt.or_else(|| ext_opt);
    |                 help: use `or(..)` instead: `or(ext_opt)`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:74:13
+  --> $DIR/unnecessary_lazy_eval.rs:75:13
    |
 LL |     let _ = opt.or_else(|| None);
    |             ^^^^----------------
@@ -49,7 +49,7 @@ LL |     let _ = opt.or_else(|| None);
    |                 help: use `or(..)` instead: `or(None)`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:75:13
+  --> $DIR/unnecessary_lazy_eval.rs:76:13
    |
 LL |     let _ = opt.get_or_insert_with(|| 2);
    |             ^^^^------------------------
@@ -57,7 +57,7 @@ LL |     let _ = opt.get_or_insert_with(|| 2);
    |                 help: use `get_or_insert(..)` instead: `get_or_insert(2)`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:76:13
+  --> $DIR/unnecessary_lazy_eval.rs:77:13
    |
 LL |     let _ = opt.ok_or_else(|| 2);
    |             ^^^^----------------
@@ -65,7 +65,7 @@ LL |     let _ = opt.ok_or_else(|| 2);
    |                 help: use `ok_or(..)` instead: `ok_or(2)`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:77:13
+  --> $DIR/unnecessary_lazy_eval.rs:78:13
    |
 LL |     let _ = nested_tuple_opt.unwrap_or_else(|| Some((1, 2)));
    |             ^^^^^^^^^^^^^^^^^-------------------------------
@@ -73,7 +73,7 @@ LL |     let _ = nested_tuple_opt.unwrap_or_else(|| Some((1, 2)));
    |                              help: use `unwrap_or(..)` instead: `unwrap_or(Some((1, 2)))`
 
 error: unnecessary closure used with `bool::then`
-  --> $DIR/unnecessary_lazy_eval.rs:78:13
+  --> $DIR/unnecessary_lazy_eval.rs:79:13
    |
 LL |     let _ = cond.then(|| astronomers_pi);
    |             ^^^^^-----------------------
@@ -81,7 +81,7 @@ LL |     let _ = cond.then(|| astronomers_pi);
    |                  help: use `then_some(..)` instead: `then_some(astronomers_pi)`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:82:13
+  --> $DIR/unnecessary_lazy_eval.rs:83:13
    |
 LL |     let _ = Some(1).unwrap_or_else(|| *r);
    |             ^^^^^^^^---------------------
@@ -89,7 +89,7 @@ LL |     let _ = Some(1).unwrap_or_else(|| *r);
    |                     help: use `unwrap_or(..)` instead: `unwrap_or(*r)`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:84:13
+  --> $DIR/unnecessary_lazy_eval.rs:85:13
    |
 LL |     let _ = Some(1).unwrap_or_else(|| *b);
    |             ^^^^^^^^---------------------
@@ -97,7 +97,7 @@ LL |     let _ = Some(1).unwrap_or_else(|| *b);
    |                     help: use `unwrap_or(..)` instead: `unwrap_or(*b)`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:86:13
+  --> $DIR/unnecessary_lazy_eval.rs:87:13
    |
 LL |     let _ = Some(1).as_ref().unwrap_or_else(|| &r);
    |             ^^^^^^^^^^^^^^^^^---------------------
@@ -105,7 +105,7 @@ LL |     let _ = Some(1).as_ref().unwrap_or_else(|| &r);
    |                              help: use `unwrap_or(..)` instead: `unwrap_or(&r)`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:87:13
+  --> $DIR/unnecessary_lazy_eval.rs:88:13
    |
 LL |     let _ = Some(1).as_ref().unwrap_or_else(|| &b);
    |             ^^^^^^^^^^^^^^^^^---------------------
@@ -113,7 +113,7 @@ LL |     let _ = Some(1).as_ref().unwrap_or_else(|| &b);
    |                              help: use `unwrap_or(..)` instead: `unwrap_or(&b)`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:90:13
+  --> $DIR/unnecessary_lazy_eval.rs:91:13
    |
 LL |     let _ = Some(10).unwrap_or_else(|| 2);
    |             ^^^^^^^^^--------------------
@@ -121,7 +121,7 @@ LL |     let _ = Some(10).unwrap_or_else(|| 2);
    |                      help: use `unwrap_or(..)` instead: `unwrap_or(2)`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:91:13
+  --> $DIR/unnecessary_lazy_eval.rs:92:13
    |
 LL |     let _ = Some(10).and_then(|_| ext_opt);
    |             ^^^^^^^^^---------------------
@@ -129,7 +129,7 @@ LL |     let _ = Some(10).and_then(|_| ext_opt);
    |                      help: use `and(..)` instead: `and(ext_opt)`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:92:28
+  --> $DIR/unnecessary_lazy_eval.rs:93:28
    |
 LL |     let _: Option<usize> = None.or_else(|| ext_opt);
    |                            ^^^^^-------------------
@@ -137,7 +137,7 @@ LL |     let _: Option<usize> = None.or_else(|| ext_opt);
    |                                 help: use `or(..)` instead: `or(ext_opt)`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:93:13
+  --> $DIR/unnecessary_lazy_eval.rs:94:13
    |
 LL |     let _ = None.get_or_insert_with(|| 2);
    |             ^^^^^------------------------
@@ -145,7 +145,7 @@ LL |     let _ = None.get_or_insert_with(|| 2);
    |                  help: use `get_or_insert(..)` instead: `get_or_insert(2)`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:94:35
+  --> $DIR/unnecessary_lazy_eval.rs:95:35
    |
 LL |     let _: Result<usize, usize> = None.ok_or_else(|| 2);
    |                                   ^^^^^----------------
@@ -153,7 +153,7 @@ LL |     let _: Result<usize, usize> = None.ok_or_else(|| 2);
    |                                        help: use `ok_or(..)` instead: `ok_or(2)`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:95:28
+  --> $DIR/unnecessary_lazy_eval.rs:96:28
    |
 LL |     let _: Option<usize> = None.or_else(|| None);
    |                            ^^^^^----------------
@@ -161,7 +161,7 @@ LL |     let _: Option<usize> = None.or_else(|| None);
    |                                 help: use `or(..)` instead: `or(None)`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:98:13
+  --> $DIR/unnecessary_lazy_eval.rs:99:13
    |
 LL |     let _ = deep.0.unwrap_or_else(|| 2);
    |             ^^^^^^^--------------------
@@ -169,7 +169,7 @@ LL |     let _ = deep.0.unwrap_or_else(|| 2);
    |                    help: use `unwrap_or(..)` instead: `unwrap_or(2)`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:99:13
+  --> $DIR/unnecessary_lazy_eval.rs:100:13
    |
 LL |     let _ = deep.0.and_then(|_| ext_opt);
    |             ^^^^^^^---------------------
@@ -177,7 +177,7 @@ LL |     let _ = deep.0.and_then(|_| ext_opt);
    |                    help: use `and(..)` instead: `and(ext_opt)`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:100:13
+  --> $DIR/unnecessary_lazy_eval.rs:101:13
    |
 LL |     let _ = deep.0.or_else(|| None);
    |             ^^^^^^^----------------
@@ -185,7 +185,7 @@ LL |     let _ = deep.0.or_else(|| None);
    |                    help: use `or(..)` instead: `or(None)`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:101:13
+  --> $DIR/unnecessary_lazy_eval.rs:102:13
    |
 LL |     let _ = deep.0.get_or_insert_with(|| 2);
    |             ^^^^^^^------------------------
@@ -193,7 +193,7 @@ LL |     let _ = deep.0.get_or_insert_with(|| 2);
    |                    help: use `get_or_insert(..)` instead: `get_or_insert(2)`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:102:13
+  --> $DIR/unnecessary_lazy_eval.rs:103:13
    |
 LL |     let _ = deep.0.ok_or_else(|| 2);
    |             ^^^^^^^----------------
@@ -201,7 +201,7 @@ LL |     let _ = deep.0.ok_or_else(|| 2);
    |                    help: use `ok_or(..)` instead: `ok_or(2)`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:132:28
+  --> $DIR/unnecessary_lazy_eval.rs:133:28
    |
 LL |     let _: Option<usize> = None.or_else(|| Some(3));
    |                            ^^^^^-------------------
@@ -209,7 +209,7 @@ LL |     let _: Option<usize> = None.or_else(|| Some(3));
    |                                 help: use `or(..)` instead: `or(Some(3))`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:133:13
+  --> $DIR/unnecessary_lazy_eval.rs:134:13
    |
 LL |     let _ = deep.0.or_else(|| Some(3));
    |             ^^^^^^^-------------------
@@ -217,7 +217,7 @@ LL |     let _ = deep.0.or_else(|| Some(3));
    |                    help: use `or(..)` instead: `or(Some(3))`
 
 error: unnecessary closure used to substitute value for `Option::None`
-  --> $DIR/unnecessary_lazy_eval.rs:134:13
+  --> $DIR/unnecessary_lazy_eval.rs:135:13
    |
 LL |     let _ = opt.or_else(|| Some(3));
    |             ^^^^-------------------
@@ -225,7 +225,7 @@ LL |     let _ = opt.or_else(|| Some(3));
    |                 help: use `or(..)` instead: `or(Some(3))`
 
 error: unnecessary closure used to substitute value for `Result::Err`
-  --> $DIR/unnecessary_lazy_eval.rs:140:13
+  --> $DIR/unnecessary_lazy_eval.rs:141:13
    |
 LL |     let _ = res2.unwrap_or_else(|_| 2);
    |             ^^^^^---------------------
@@ -233,7 +233,7 @@ LL |     let _ = res2.unwrap_or_else(|_| 2);
    |                  help: use `unwrap_or(..)` instead: `unwrap_or(2)`
 
 error: unnecessary closure used to substitute value for `Result::Err`
-  --> $DIR/unnecessary_lazy_eval.rs:141:13
+  --> $DIR/unnecessary_lazy_eval.rs:142:13
    |
 LL |     let _ = res2.unwrap_or_else(|_| astronomers_pi);
    |             ^^^^^----------------------------------
@@ -241,7 +241,7 @@ LL |     let _ = res2.unwrap_or_else(|_| astronomers_pi);
    |                  help: use `unwrap_or(..)` instead: `unwrap_or(astronomers_pi)`
 
 error: unnecessary closure used to substitute value for `Result::Err`
-  --> $DIR/unnecessary_lazy_eval.rs:142:13
+  --> $DIR/unnecessary_lazy_eval.rs:143:13
    |
 LL |     let _ = res2.unwrap_or_else(|_| ext_str.some_field);
    |             ^^^^^--------------------------------------
@@ -249,7 +249,7 @@ LL |     let _ = res2.unwrap_or_else(|_| ext_str.some_field);
    |                  help: use `unwrap_or(..)` instead: `unwrap_or(ext_str.some_field)`
 
 error: unnecessary closure used to substitute value for `Result::Err`
-  --> $DIR/unnecessary_lazy_eval.rs:164:35
+  --> $DIR/unnecessary_lazy_eval.rs:165:35
    |
 LL |     let _: Result<usize, usize> = res.and_then(|_| Err(2));
    |                                   ^^^^--------------------
@@ -257,7 +257,7 @@ LL |     let _: Result<usize, usize> = res.and_then(|_| Err(2));
    |                                       help: use `and(..)` instead: `and(Err(2))`
 
 error: unnecessary closure used to substitute value for `Result::Err`
-  --> $DIR/unnecessary_lazy_eval.rs:165:35
+  --> $DIR/unnecessary_lazy_eval.rs:166:35
    |
 LL |     let _: Result<usize, usize> = res.and_then(|_| Err(astronomers_pi));
    |                                   ^^^^---------------------------------
@@ -265,7 +265,7 @@ LL |     let _: Result<usize, usize> = res.and_then(|_| Err(astronomers_pi));
    |                                       help: use `and(..)` instead: `and(Err(astronomers_pi))`
 
 error: unnecessary closure used to substitute value for `Result::Err`
-  --> $DIR/unnecessary_lazy_eval.rs:166:35
+  --> $DIR/unnecessary_lazy_eval.rs:167:35
    |
 LL |     let _: Result<usize, usize> = res.and_then(|_| Err(ext_str.some_field));
    |                                   ^^^^-------------------------------------
@@ -273,7 +273,7 @@ LL |     let _: Result<usize, usize> = res.and_then(|_| Err(ext_str.some_field))
    |                                       help: use `and(..)` instead: `and(Err(ext_str.some_field))`
 
 error: unnecessary closure used to substitute value for `Result::Err`
-  --> $DIR/unnecessary_lazy_eval.rs:168:35
+  --> $DIR/unnecessary_lazy_eval.rs:169:35
    |
 LL |     let _: Result<usize, usize> = res.or_else(|_| Ok(2));
    |                                   ^^^^------------------
@@ -281,7 +281,7 @@ LL |     let _: Result<usize, usize> = res.or_else(|_| Ok(2));
    |                                       help: use `or(..)` instead: `or(Ok(2))`
 
 error: unnecessary closure used to substitute value for `Result::Err`
-  --> $DIR/unnecessary_lazy_eval.rs:169:35
+  --> $DIR/unnecessary_lazy_eval.rs:170:35
    |
 LL |     let _: Result<usize, usize> = res.or_else(|_| Ok(astronomers_pi));
    |                                   ^^^^-------------------------------
@@ -289,7 +289,7 @@ LL |     let _: Result<usize, usize> = res.or_else(|_| Ok(astronomers_pi));
    |                                       help: use `or(..)` instead: `or(Ok(astronomers_pi))`
 
 error: unnecessary closure used to substitute value for `Result::Err`
-  --> $DIR/unnecessary_lazy_eval.rs:170:35
+  --> $DIR/unnecessary_lazy_eval.rs:171:35
    |
 LL |     let _: Result<usize, usize> = res.or_else(|_| Ok(ext_str.some_field));
    |                                   ^^^^-----------------------------------
@@ -297,7 +297,7 @@ LL |     let _: Result<usize, usize> = res.or_else(|_| Ok(ext_str.some_field));
    |                                       help: use `or(..)` instead: `or(Ok(ext_str.some_field))`
 
 error: unnecessary closure used to substitute value for `Result::Err`
-  --> $DIR/unnecessary_lazy_eval.rs:171:35
+  --> $DIR/unnecessary_lazy_eval.rs:172:35
    |
 LL |       let _: Result<usize, usize> = res.
    |  ___________________________________^
diff --git a/tests/ui/unnecessary_lazy_eval_unfixable.rs b/tests/ui/unnecessary_lazy_eval_unfixable.rs
index b05dd143bfd..b4a1f81679a 100644
--- a/tests/ui/unnecessary_lazy_eval_unfixable.rs
+++ b/tests/ui/unnecessary_lazy_eval_unfixable.rs
@@ -1,4 +1,5 @@
 #![warn(clippy::unnecessary_lazy_evaluations)]
+#![allow(clippy::unnecessary_literal_unwrap)]
 
 struct Deep(Option<usize>);
 
diff --git a/tests/ui/unnecessary_lazy_eval_unfixable.stderr b/tests/ui/unnecessary_lazy_eval_unfixable.stderr
index 20acab6e844..7f353ba0698 100644
--- a/tests/ui/unnecessary_lazy_eval_unfixable.stderr
+++ b/tests/ui/unnecessary_lazy_eval_unfixable.stderr
@@ -1,5 +1,5 @@
 error: unnecessary closure used to substitute value for `Result::Err`
-  --> $DIR/unnecessary_lazy_eval_unfixable.rs:12:13
+  --> $DIR/unnecessary_lazy_eval_unfixable.rs:13:13
    |
 LL |     let _ = Ok(1).unwrap_or_else(|()| 2);
    |             ^^^^^^----------------------
@@ -9,7 +9,7 @@ LL |     let _ = Ok(1).unwrap_or_else(|()| 2);
    = note: `-D clippy::unnecessary-lazy-evaluations` implied by `-D warnings`
 
 error: unnecessary closure used to substitute value for `Result::Err`
-  --> $DIR/unnecessary_lazy_eval_unfixable.rs:16:13
+  --> $DIR/unnecessary_lazy_eval_unfixable.rs:17:13
    |
 LL |     let _ = Ok(1).unwrap_or_else(|e::E| 2);
    |             ^^^^^^------------------------
@@ -17,7 +17,7 @@ LL |     let _ = Ok(1).unwrap_or_else(|e::E| 2);
    |                   help: use `unwrap_or(..)` instead: `unwrap_or(2)`
 
 error: unnecessary closure used to substitute value for `Result::Err`
-  --> $DIR/unnecessary_lazy_eval_unfixable.rs:17:13
+  --> $DIR/unnecessary_lazy_eval_unfixable.rs:18:13
    |
 LL |     let _ = Ok(1).unwrap_or_else(|SomeStruct { .. }| 2);
    |             ^^^^^^-------------------------------------
diff --git a/tests/ui/unnecessary_literal_unwrap.fixed b/tests/ui/unnecessary_literal_unwrap.fixed
new file mode 100644
index 00000000000..630a1bea3c8
--- /dev/null
+++ b/tests/ui/unnecessary_literal_unwrap.fixed
@@ -0,0 +1,78 @@
+//@run-rustfix
+#![warn(clippy::unnecessary_literal_unwrap)]
+#![allow(unreachable_code)]
+#![allow(
+    clippy::unnecessary_lazy_evaluations,
+    clippy::diverging_sub_expression,
+    clippy::let_unit_value,
+    clippy::no_effect
+)]
+
+fn unwrap_option_some() {
+    let _val = 1;
+    let _val = 1;
+
+    1;
+    1;
+}
+
+fn unwrap_option_none() {
+    let _val = panic!();
+    let _val = panic!("this always happens");
+
+    panic!();
+    panic!("this always happens");
+}
+
+fn unwrap_result_ok() {
+    let _val = 1;
+    let _val = 1;
+    let _val = panic!("{:?}", 1);
+    let _val = panic!("{1}: {:?}", 1, "this always happens");
+
+    1;
+    1;
+    panic!("{:?}", 1);
+    panic!("{1}: {:?}", 1, "this always happens");
+}
+
+fn unwrap_result_err() {
+    let _val = 1;
+    let _val = 1;
+    let _val = panic!("{:?}", 1);
+    let _val = panic!("{1}: {:?}", 1, "this always happens");
+
+    1;
+    1;
+    panic!("{:?}", 1);
+    panic!("{1}: {:?}", 1, "this always happens");
+}
+
+fn unwrap_methods_option() {
+    let _val = 1;
+    let _val = 1;
+    let _val = 1;
+
+    1;
+    1;
+    1;
+}
+
+fn unwrap_methods_result() {
+    let _val = 1;
+    let _val = 1;
+    let _val = 1;
+
+    1;
+    1;
+    1;
+}
+
+fn main() {
+    unwrap_option_some();
+    unwrap_option_none();
+    unwrap_result_ok();
+    unwrap_result_err();
+    unwrap_methods_option();
+    unwrap_methods_result();
+}
diff --git a/tests/ui/unnecessary_literal_unwrap.rs b/tests/ui/unnecessary_literal_unwrap.rs
new file mode 100644
index 00000000000..14f92cb370f
--- /dev/null
+++ b/tests/ui/unnecessary_literal_unwrap.rs
@@ -0,0 +1,78 @@
+//@run-rustfix
+#![warn(clippy::unnecessary_literal_unwrap)]
+#![allow(unreachable_code)]
+#![allow(
+    clippy::unnecessary_lazy_evaluations,
+    clippy::diverging_sub_expression,
+    clippy::let_unit_value,
+    clippy::no_effect
+)]
+
+fn unwrap_option_some() {
+    let _val = Some(1).unwrap();
+    let _val = Some(1).expect("this never happens");
+
+    Some(1).unwrap();
+    Some(1).expect("this never happens");
+}
+
+fn unwrap_option_none() {
+    let _val = None::<()>.unwrap();
+    let _val = None::<()>.expect("this always happens");
+
+    None::<()>.unwrap();
+    None::<()>.expect("this always happens");
+}
+
+fn unwrap_result_ok() {
+    let _val = Ok::<_, ()>(1).unwrap();
+    let _val = Ok::<_, ()>(1).expect("this never happens");
+    let _val = Ok::<_, ()>(1).unwrap_err();
+    let _val = Ok::<_, ()>(1).expect_err("this always happens");
+
+    Ok::<_, ()>(1).unwrap();
+    Ok::<_, ()>(1).expect("this never happens");
+    Ok::<_, ()>(1).unwrap_err();
+    Ok::<_, ()>(1).expect_err("this always happens");
+}
+
+fn unwrap_result_err() {
+    let _val = Err::<(), _>(1).unwrap_err();
+    let _val = Err::<(), _>(1).expect_err("this never happens");
+    let _val = Err::<(), _>(1).unwrap();
+    let _val = Err::<(), _>(1).expect("this always happens");
+
+    Err::<(), _>(1).unwrap_err();
+    Err::<(), _>(1).expect_err("this never happens");
+    Err::<(), _>(1).unwrap();
+    Err::<(), _>(1).expect("this always happens");
+}
+
+fn unwrap_methods_option() {
+    let _val = Some(1).unwrap_or(2);
+    let _val = Some(1).unwrap_or_default();
+    let _val = Some(1).unwrap_or_else(|| 2);
+
+    Some(1).unwrap_or(2);
+    Some(1).unwrap_or_default();
+    Some(1).unwrap_or_else(|| 2);
+}
+
+fn unwrap_methods_result() {
+    let _val = Ok::<_, ()>(1).unwrap_or(2);
+    let _val = Ok::<_, ()>(1).unwrap_or_default();
+    let _val = Ok::<_, ()>(1).unwrap_or_else(|_| 2);
+
+    Ok::<_, ()>(1).unwrap_or(2);
+    Ok::<_, ()>(1).unwrap_or_default();
+    Ok::<_, ()>(1).unwrap_or_else(|_| 2);
+}
+
+fn main() {
+    unwrap_option_some();
+    unwrap_option_none();
+    unwrap_result_ok();
+    unwrap_result_err();
+    unwrap_methods_option();
+    unwrap_methods_result();
+}
diff --git a/tests/ui/unnecessary_literal_unwrap.stderr b/tests/ui/unnecessary_literal_unwrap.stderr
new file mode 100644
index 00000000000..0c71ee05323
--- /dev/null
+++ b/tests/ui/unnecessary_literal_unwrap.stderr
@@ -0,0 +1,413 @@
+error: used `unwrap()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap.rs:12:16
+   |
+LL |     let _val = Some(1).unwrap();
+   |                ^^^^^^^^^^^^^^^^
+   |
+   = note: `-D clippy::unnecessary-literal-unwrap` implied by `-D warnings`
+help: remove the `Some` and `unwrap()`
+   |
+LL -     let _val = Some(1).unwrap();
+LL +     let _val = 1;
+   |
+
+error: used `expect()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap.rs:13:16
+   |
+LL |     let _val = Some(1).expect("this never happens");
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Some` and `expect()`
+   |
+LL -     let _val = Some(1).expect("this never happens");
+LL +     let _val = 1;
+   |
+
+error: used `unwrap()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap.rs:15:5
+   |
+LL |     Some(1).unwrap();
+   |     ^^^^^^^^^^^^^^^^
+   |
+help: remove the `Some` and `unwrap()`
+   |
+LL -     Some(1).unwrap();
+LL +     1;
+   |
+
+error: used `expect()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap.rs:16:5
+   |
+LL |     Some(1).expect("this never happens");
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Some` and `expect()`
+   |
+LL -     Some(1).expect("this never happens");
+LL +     1;
+   |
+
+error: used `unwrap()` on `None` value
+  --> $DIR/unnecessary_literal_unwrap.rs:20:16
+   |
+LL |     let _val = None::<()>.unwrap();
+   |                ^^^^^^^^^^^^^^^^^^^ help: remove the `None` and `unwrap()`: `panic!()`
+
+error: used `expect()` on `None` value
+  --> $DIR/unnecessary_literal_unwrap.rs:21:16
+   |
+LL |     let _val = None::<()>.expect("this always happens");
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `None` and `expect()`
+   |
+LL |     let _val = panic!("this always happens");
+   |                ~~~~~~~                     ~
+
+error: used `unwrap()` on `None` value
+  --> $DIR/unnecessary_literal_unwrap.rs:23:5
+   |
+LL |     None::<()>.unwrap();
+   |     ^^^^^^^^^^^^^^^^^^^ help: remove the `None` and `unwrap()`: `panic!()`
+
+error: used `expect()` on `None` value
+  --> $DIR/unnecessary_literal_unwrap.rs:24:5
+   |
+LL |     None::<()>.expect("this always happens");
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `None` and `expect()`
+   |
+LL |     panic!("this always happens");
+   |     ~~~~~~~                     ~
+
+error: used `unwrap()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap.rs:28:16
+   |
+LL |     let _val = Ok::<_, ()>(1).unwrap();
+   |                ^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap()`
+   |
+LL -     let _val = Ok::<_, ()>(1).unwrap();
+LL +     let _val = 1;
+   |
+
+error: used `expect()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap.rs:29:16
+   |
+LL |     let _val = Ok::<_, ()>(1).expect("this never happens");
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `expect()`
+   |
+LL -     let _val = Ok::<_, ()>(1).expect("this never happens");
+LL +     let _val = 1;
+   |
+
+error: used `unwrap_err()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap.rs:30:16
+   |
+LL |     let _val = Ok::<_, ()>(1).unwrap_err();
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap_err()`
+   |
+LL |     let _val = panic!("{:?}", 1);
+   |                ~~~~~~~~~~~~~~  ~
+
+error: used `expect_err()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap.rs:31:16
+   |
+LL |     let _val = Ok::<_, ()>(1).expect_err("this always happens");
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `expect_err()`
+   |
+LL |     let _val = panic!("{1}: {:?}", 1, "this always happens");
+   |                ~~~~~~~~~~~~~~~~~~~  ~
+
+error: used `unwrap()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap.rs:33:5
+   |
+LL |     Ok::<_, ()>(1).unwrap();
+   |     ^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap()`
+   |
+LL -     Ok::<_, ()>(1).unwrap();
+LL +     1;
+   |
+
+error: used `expect()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap.rs:34:5
+   |
+LL |     Ok::<_, ()>(1).expect("this never happens");
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `expect()`
+   |
+LL -     Ok::<_, ()>(1).expect("this never happens");
+LL +     1;
+   |
+
+error: used `unwrap_err()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap.rs:35:5
+   |
+LL |     Ok::<_, ()>(1).unwrap_err();
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap_err()`
+   |
+LL |     panic!("{:?}", 1);
+   |     ~~~~~~~~~~~~~~  ~
+
+error: used `expect_err()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap.rs:36:5
+   |
+LL |     Ok::<_, ()>(1).expect_err("this always happens");
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `expect_err()`
+   |
+LL |     panic!("{1}: {:?}", 1, "this always happens");
+   |     ~~~~~~~~~~~~~~~~~~~  ~
+
+error: used `unwrap_err()` on `Err` value
+  --> $DIR/unnecessary_literal_unwrap.rs:40:16
+   |
+LL |     let _val = Err::<(), _>(1).unwrap_err();
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Err` and `unwrap_err()`
+   |
+LL -     let _val = Err::<(), _>(1).unwrap_err();
+LL +     let _val = 1;
+   |
+
+error: used `expect_err()` on `Err` value
+  --> $DIR/unnecessary_literal_unwrap.rs:41:16
+   |
+LL |     let _val = Err::<(), _>(1).expect_err("this never happens");
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Err` and `expect_err()`
+   |
+LL -     let _val = Err::<(), _>(1).expect_err("this never happens");
+LL +     let _val = 1;
+   |
+
+error: used `unwrap()` on `Err` value
+  --> $DIR/unnecessary_literal_unwrap.rs:42:16
+   |
+LL |     let _val = Err::<(), _>(1).unwrap();
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Err` and `unwrap()`
+   |
+LL |     let _val = panic!("{:?}", 1);
+   |                ~~~~~~~~~~~~~~  ~
+
+error: used `expect()` on `Err` value
+  --> $DIR/unnecessary_literal_unwrap.rs:43:16
+   |
+LL |     let _val = Err::<(), _>(1).expect("this always happens");
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Err` and `expect()`
+   |
+LL |     let _val = panic!("{1}: {:?}", 1, "this always happens");
+   |                ~~~~~~~~~~~~~~~~~~~  ~
+
+error: used `unwrap_err()` on `Err` value
+  --> $DIR/unnecessary_literal_unwrap.rs:45:5
+   |
+LL |     Err::<(), _>(1).unwrap_err();
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Err` and `unwrap_err()`
+   |
+LL -     Err::<(), _>(1).unwrap_err();
+LL +     1;
+   |
+
+error: used `expect_err()` on `Err` value
+  --> $DIR/unnecessary_literal_unwrap.rs:46:5
+   |
+LL |     Err::<(), _>(1).expect_err("this never happens");
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Err` and `expect_err()`
+   |
+LL -     Err::<(), _>(1).expect_err("this never happens");
+LL +     1;
+   |
+
+error: used `unwrap()` on `Err` value
+  --> $DIR/unnecessary_literal_unwrap.rs:47:5
+   |
+LL |     Err::<(), _>(1).unwrap();
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Err` and `unwrap()`
+   |
+LL |     panic!("{:?}", 1);
+   |     ~~~~~~~~~~~~~~  ~
+
+error: used `expect()` on `Err` value
+  --> $DIR/unnecessary_literal_unwrap.rs:48:5
+   |
+LL |     Err::<(), _>(1).expect("this always happens");
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Err` and `expect()`
+   |
+LL |     panic!("{1}: {:?}", 1, "this always happens");
+   |     ~~~~~~~~~~~~~~~~~~~  ~
+
+error: used `unwrap_or()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap.rs:52:16
+   |
+LL |     let _val = Some(1).unwrap_or(2);
+   |                ^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Some` and `unwrap_or()`
+   |
+LL -     let _val = Some(1).unwrap_or(2);
+LL +     let _val = 1;
+   |
+
+error: used `unwrap_or_default()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap.rs:53:16
+   |
+LL |     let _val = Some(1).unwrap_or_default();
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Some` and `unwrap_or_default()`
+   |
+LL -     let _val = Some(1).unwrap_or_default();
+LL +     let _val = 1;
+   |
+
+error: used `unwrap_or_else()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap.rs:54:16
+   |
+LL |     let _val = Some(1).unwrap_or_else(|| 2);
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Some` and `unwrap_or_else()`
+   |
+LL -     let _val = Some(1).unwrap_or_else(|| 2);
+LL +     let _val = 1;
+   |
+
+error: used `unwrap_or()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap.rs:56:5
+   |
+LL |     Some(1).unwrap_or(2);
+   |     ^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Some` and `unwrap_or()`
+   |
+LL -     Some(1).unwrap_or(2);
+LL +     1;
+   |
+
+error: used `unwrap_or_default()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap.rs:57:5
+   |
+LL |     Some(1).unwrap_or_default();
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Some` and `unwrap_or_default()`
+   |
+LL -     Some(1).unwrap_or_default();
+LL +     1;
+   |
+
+error: used `unwrap_or_else()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap.rs:58:5
+   |
+LL |     Some(1).unwrap_or_else(|| 2);
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Some` and `unwrap_or_else()`
+   |
+LL -     Some(1).unwrap_or_else(|| 2);
+LL +     1;
+   |
+
+error: used `unwrap_or()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap.rs:62:16
+   |
+LL |     let _val = Ok::<_, ()>(1).unwrap_or(2);
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap_or()`
+   |
+LL -     let _val = Ok::<_, ()>(1).unwrap_or(2);
+LL +     let _val = 1;
+   |
+
+error: used `unwrap_or_default()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap.rs:63:16
+   |
+LL |     let _val = Ok::<_, ()>(1).unwrap_or_default();
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap_or_default()`
+   |
+LL -     let _val = Ok::<_, ()>(1).unwrap_or_default();
+LL +     let _val = 1;
+   |
+
+error: used `unwrap_or_else()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap.rs:64:16
+   |
+LL |     let _val = Ok::<_, ()>(1).unwrap_or_else(|_| 2);
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap_or_else()`
+   |
+LL -     let _val = Ok::<_, ()>(1).unwrap_or_else(|_| 2);
+LL +     let _val = 1;
+   |
+
+error: used `unwrap_or()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap.rs:66:5
+   |
+LL |     Ok::<_, ()>(1).unwrap_or(2);
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap_or()`
+   |
+LL -     Ok::<_, ()>(1).unwrap_or(2);
+LL +     1;
+   |
+
+error: used `unwrap_or_default()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap.rs:67:5
+   |
+LL |     Ok::<_, ()>(1).unwrap_or_default();
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap_or_default()`
+   |
+LL -     Ok::<_, ()>(1).unwrap_or_default();
+LL +     1;
+   |
+
+error: used `unwrap_or_else()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap.rs:68:5
+   |
+LL |     Ok::<_, ()>(1).unwrap_or_else(|_| 2);
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap_or_else()`
+   |
+LL -     Ok::<_, ()>(1).unwrap_or_else(|_| 2);
+LL +     1;
+   |
+
+error: aborting due to 36 previous errors
+
diff --git a/tests/ui/unnecessary_literal_unwrap_unfixable.rs b/tests/ui/unnecessary_literal_unwrap_unfixable.rs
new file mode 100644
index 00000000000..711fdce3962
--- /dev/null
+++ b/tests/ui/unnecessary_literal_unwrap_unfixable.rs
@@ -0,0 +1,116 @@
+#![warn(clippy::unnecessary_literal_unwrap)]
+#![allow(unreachable_code)]
+#![allow(clippy::unnecessary_lazy_evaluations, clippy::let_unit_value)]
+
+fn unwrap_option_some() {
+    let val = Some(1);
+    let _val2 = val.unwrap();
+    let _val2 = val.expect("this never happens");
+}
+
+fn unwrap_option_some_context() {
+    let _val = Some::<usize>([1, 2, 3].iter().sum()).unwrap();
+    let _val = Some::<usize>([1, 2, 3].iter().sum()).expect("this never happens");
+
+    let val = Some::<usize>([1, 2, 3].iter().sum());
+    let _val2 = val.unwrap();
+    let _val2 = val.expect("this never happens");
+}
+
+fn unwrap_option_none() {
+    let val = None::<()>;
+    let _val2 = val.unwrap();
+    let _val2 = val.expect("this always happens");
+}
+
+fn unwrap_result_ok() {
+    let val = Ok::<_, ()>(1);
+    let _val2 = val.unwrap();
+    let _val2 = val.expect("this never happens");
+    let _val2 = val.unwrap_err();
+    let _val2 = val.expect_err("this always happens");
+}
+
+fn unwrap_result_ok_context() {
+    let _val = Ok::<usize, ()>([1, 2, 3].iter().sum()).unwrap();
+    let _val = Ok::<usize, ()>([1, 2, 3].iter().sum()).expect("this never happens");
+    let _val = Ok::<usize, ()>([1, 2, 3].iter().sum()).unwrap_err();
+    let _val = Ok::<usize, ()>([1, 2, 3].iter().sum()).expect_err("this always happens");
+
+    let val = Ok::<usize, ()>([1, 2, 3].iter().sum());
+    let _val2 = val.unwrap();
+    let _val2 = val.expect("this never happens");
+    let _val2 = val.unwrap_err();
+    let _val2 = val.expect_err("this always happens");
+}
+
+fn unwrap_result_err() {
+    let val = Err::<(), _>(1);
+    let _val2 = val.unwrap_err();
+    let _val2 = val.expect_err("this never happens");
+    let _val2 = val.unwrap();
+    let _val2 = val.expect("this always happens");
+}
+
+fn unwrap_result_err_context() {
+    let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap_err();
+    let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect_err("this never happens");
+    let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap();
+    let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect("this always happens");
+
+    let val = Err::<(), usize>([1, 2, 3].iter().sum());
+    let _val2 = val.unwrap_err();
+    let _val2 = val.expect_err("this never happens");
+    let _val2 = val.unwrap();
+    let _val2 = val.expect("this always happens");
+}
+
+fn unwrap_methods_option() {
+    let val = Some(1);
+    let _val2 = val.unwrap_or(2);
+    let _val2 = val.unwrap_or_default();
+    let _val2 = val.unwrap_or_else(|| 2);
+}
+
+fn unwrap_methods_option_context() {
+    let _val = Some::<usize>([1, 2, 3].iter().sum()).unwrap_or(2);
+    let _val = Some::<usize>([1, 2, 3].iter().sum()).unwrap_or_default();
+    let _val = Some::<usize>([1, 2, 3].iter().sum()).unwrap_or_else(|| 2);
+
+    let val = Some::<usize>([1, 2, 3].iter().sum());
+    let _val2 = val.unwrap_or(2);
+    let _val2 = val.unwrap_or_default();
+    let _val2 = val.unwrap_or_else(|| 2);
+}
+
+fn unwrap_methods_result() {
+    let val = Ok::<_, ()>(1);
+    let _val2 = val.unwrap_or(2);
+    let _val2 = val.unwrap_or_default();
+    let _val2 = val.unwrap_or_else(|_| 2);
+}
+
+fn unwrap_methods_result_context() {
+    let _val = Ok::<usize, ()>([1, 2, 3].iter().sum()).unwrap_or(2);
+    let _val = Ok::<usize, ()>([1, 2, 3].iter().sum()).unwrap_or_default();
+    let _val = Ok::<usize, ()>([1, 2, 3].iter().sum()).unwrap_or_else(|_| 2);
+
+    let val = Ok::<usize, ()>([1, 2, 3].iter().sum());
+    let _val2 = val.unwrap_or(2);
+    let _val2 = val.unwrap_or_default();
+    let _val2 = val.unwrap_or_else(|_| 2);
+}
+
+fn main() {
+    unwrap_option_some();
+    unwrap_option_some_context();
+    unwrap_option_none();
+    unwrap_result_ok();
+    unwrap_result_ok_context();
+    unwrap_result_err();
+    unwrap_result_err_context();
+    unwrap_methods_option();
+    unwrap_methods_option_context();
+    unwrap_methods_result();
+    unwrap_methods_result_context();
+}
diff --git a/tests/ui/unnecessary_literal_unwrap_unfixable.stderr b/tests/ui/unnecessary_literal_unwrap_unfixable.stderr
new file mode 100644
index 00000000000..feb9325b77a
--- /dev/null
+++ b/tests/ui/unnecessary_literal_unwrap_unfixable.stderr
@@ -0,0 +1,603 @@
+error: used `unwrap()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:7:17
+   |
+LL |     let _val2 = val.unwrap();
+   |                 ^^^^^^^^^^^^
+   |
+help: remove the `Some` and `unwrap()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:6:15
+   |
+LL |     let val = Some(1);
+   |               ^^^^^^^
+   = note: `-D clippy::unnecessary-literal-unwrap` implied by `-D warnings`
+
+error: used `expect()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:8:17
+   |
+LL |     let _val2 = val.expect("this never happens");
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Some` and `expect()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:6:15
+   |
+LL |     let val = Some(1);
+   |               ^^^^^^^
+
+error: used `unwrap()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:12:16
+   |
+LL |     let _val = Some::<usize>([1, 2, 3].iter().sum()).unwrap();
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Some` and `unwrap()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:12:16
+   |
+LL |     let _val = Some::<usize>([1, 2, 3].iter().sum()).unwrap();
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `expect()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:13:16
+   |
+LL |     let _val = Some::<usize>([1, 2, 3].iter().sum()).expect("this never happens");
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Some` and `expect()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:13:16
+   |
+LL |     let _val = Some::<usize>([1, 2, 3].iter().sum()).expect("this never happens");
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `unwrap()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:16:17
+   |
+LL |     let _val2 = val.unwrap();
+   |                 ^^^^^^^^^^^^
+   |
+help: remove the `Some` and `unwrap()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:15:15
+   |
+LL |     let val = Some::<usize>([1, 2, 3].iter().sum());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `expect()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:17:17
+   |
+LL |     let _val2 = val.expect("this never happens");
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Some` and `expect()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:15:15
+   |
+LL |     let val = Some::<usize>([1, 2, 3].iter().sum());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `unwrap()` on `None` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:22:17
+   |
+LL |     let _val2 = val.unwrap();
+   |                 ^^^^^^^^^^^^
+   |
+help: remove the `None` and `unwrap()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:21:15
+   |
+LL |     let val = None::<()>;
+   |               ^^^^^^^^^^
+
+error: used `expect()` on `None` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:23:17
+   |
+LL |     let _val2 = val.expect("this always happens");
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `None` and `expect()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:21:15
+   |
+LL |     let val = None::<()>;
+   |               ^^^^^^^^^^
+
+error: used `unwrap()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:28:17
+   |
+LL |     let _val2 = val.unwrap();
+   |                 ^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:27:15
+   |
+LL |     let val = Ok::<_, ()>(1);
+   |               ^^^^^^^^^^^^^^
+
+error: used `expect()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:29:17
+   |
+LL |     let _val2 = val.expect("this never happens");
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `expect()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:27:15
+   |
+LL |     let val = Ok::<_, ()>(1);
+   |               ^^^^^^^^^^^^^^
+
+error: used `unwrap_err()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:30:17
+   |
+LL |     let _val2 = val.unwrap_err();
+   |                 ^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap_err()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:27:15
+   |
+LL |     let val = Ok::<_, ()>(1);
+   |               ^^^^^^^^^^^^^^
+
+error: used `expect_err()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:31:17
+   |
+LL |     let _val2 = val.expect_err("this always happens");
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `expect_err()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:27:15
+   |
+LL |     let val = Ok::<_, ()>(1);
+   |               ^^^^^^^^^^^^^^
+
+error: used `unwrap()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:35:16
+   |
+LL |     let _val = Ok::<usize, ()>([1, 2, 3].iter().sum()).unwrap();
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:35:16
+   |
+LL |     let _val = Ok::<usize, ()>([1, 2, 3].iter().sum()).unwrap();
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `expect()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:36:16
+   |
+LL |     let _val = Ok::<usize, ()>([1, 2, 3].iter().sum()).expect("this never happens");
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `expect()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:36:16
+   |
+LL |     let _val = Ok::<usize, ()>([1, 2, 3].iter().sum()).expect("this never happens");
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `unwrap_err()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:37:16
+   |
+LL |     let _val = Ok::<usize, ()>([1, 2, 3].iter().sum()).unwrap_err();
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap_err()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:37:16
+   |
+LL |     let _val = Ok::<usize, ()>([1, 2, 3].iter().sum()).unwrap_err();
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `expect_err()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:38:16
+   |
+LL |     let _val = Ok::<usize, ()>([1, 2, 3].iter().sum()).expect_err("this always happens");
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `expect_err()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:38:16
+   |
+LL |     let _val = Ok::<usize, ()>([1, 2, 3].iter().sum()).expect_err("this always happens");
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `unwrap()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:41:17
+   |
+LL |     let _val2 = val.unwrap();
+   |                 ^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:40:15
+   |
+LL |     let val = Ok::<usize, ()>([1, 2, 3].iter().sum());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `expect()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:42:17
+   |
+LL |     let _val2 = val.expect("this never happens");
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `expect()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:40:15
+   |
+LL |     let val = Ok::<usize, ()>([1, 2, 3].iter().sum());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `unwrap_err()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:43:17
+   |
+LL |     let _val2 = val.unwrap_err();
+   |                 ^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap_err()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:40:15
+   |
+LL |     let val = Ok::<usize, ()>([1, 2, 3].iter().sum());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `expect_err()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:44:17
+   |
+LL |     let _val2 = val.expect_err("this always happens");
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `expect_err()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:40:15
+   |
+LL |     let val = Ok::<usize, ()>([1, 2, 3].iter().sum());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `unwrap_err()` on `Err` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:49:17
+   |
+LL |     let _val2 = val.unwrap_err();
+   |                 ^^^^^^^^^^^^^^^^
+   |
+help: remove the `Err` and `unwrap_err()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:48:15
+   |
+LL |     let val = Err::<(), _>(1);
+   |               ^^^^^^^^^^^^^^^
+
+error: used `expect_err()` on `Err` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:50:17
+   |
+LL |     let _val2 = val.expect_err("this never happens");
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Err` and `expect_err()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:48:15
+   |
+LL |     let val = Err::<(), _>(1);
+   |               ^^^^^^^^^^^^^^^
+
+error: used `unwrap()` on `Err` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:51:17
+   |
+LL |     let _val2 = val.unwrap();
+   |                 ^^^^^^^^^^^^
+   |
+help: remove the `Err` and `unwrap()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:48:15
+   |
+LL |     let val = Err::<(), _>(1);
+   |               ^^^^^^^^^^^^^^^
+
+error: used `expect()` on `Err` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:52:17
+   |
+LL |     let _val2 = val.expect("this always happens");
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Err` and `expect()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:48:15
+   |
+LL |     let val = Err::<(), _>(1);
+   |               ^^^^^^^^^^^^^^^
+
+error: used `unwrap_err()` on `Err` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:56:16
+   |
+LL |     let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap_err();
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Err` and `unwrap_err()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:56:16
+   |
+LL |     let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap_err();
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `expect_err()` on `Err` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:57:16
+   |
+LL |     let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect_err("this never happens");
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Err` and `expect_err()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:57:16
+   |
+LL |     let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect_err("this never happens");
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `unwrap()` on `Err` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:58:16
+   |
+LL |     let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap();
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Err` and `unwrap()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:58:16
+   |
+LL |     let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap();
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `expect()` on `Err` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:59:16
+   |
+LL |     let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect("this always happens");
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Err` and `expect()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:59:16
+   |
+LL |     let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect("this always happens");
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `unwrap_err()` on `Err` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:62:17
+   |
+LL |     let _val2 = val.unwrap_err();
+   |                 ^^^^^^^^^^^^^^^^
+   |
+help: remove the `Err` and `unwrap_err()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:61:15
+   |
+LL |     let val = Err::<(), usize>([1, 2, 3].iter().sum());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `expect_err()` on `Err` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:63:17
+   |
+LL |     let _val2 = val.expect_err("this never happens");
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Err` and `expect_err()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:61:15
+   |
+LL |     let val = Err::<(), usize>([1, 2, 3].iter().sum());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `unwrap()` on `Err` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:64:17
+   |
+LL |     let _val2 = val.unwrap();
+   |                 ^^^^^^^^^^^^
+   |
+help: remove the `Err` and `unwrap()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:61:15
+   |
+LL |     let val = Err::<(), usize>([1, 2, 3].iter().sum());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `expect()` on `Err` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:65:17
+   |
+LL |     let _val2 = val.expect("this always happens");
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Err` and `expect()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:61:15
+   |
+LL |     let val = Err::<(), usize>([1, 2, 3].iter().sum());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `unwrap_or()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:70:17
+   |
+LL |     let _val2 = val.unwrap_or(2);
+   |                 ^^^^^^^^^^^^^^^^
+   |
+help: remove the `Some` and `unwrap_or()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:69:15
+   |
+LL |     let val = Some(1);
+   |               ^^^^^^^
+
+error: used `unwrap_or_default()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:71:17
+   |
+LL |     let _val2 = val.unwrap_or_default();
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Some` and `unwrap_or_default()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:69:15
+   |
+LL |     let val = Some(1);
+   |               ^^^^^^^
+
+error: used `unwrap_or_else()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:72:17
+   |
+LL |     let _val2 = val.unwrap_or_else(|| 2);
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Some` and `unwrap_or_else()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:69:15
+   |
+LL |     let val = Some(1);
+   |               ^^^^^^^
+
+error: used `unwrap_or()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:76:16
+   |
+LL |     let _val = Some::<usize>([1, 2, 3].iter().sum()).unwrap_or(2);
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Some` and `unwrap_or()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:76:16
+   |
+LL |     let _val = Some::<usize>([1, 2, 3].iter().sum()).unwrap_or(2);
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `unwrap_or_default()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:77:16
+   |
+LL |     let _val = Some::<usize>([1, 2, 3].iter().sum()).unwrap_or_default();
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Some` and `unwrap_or_default()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:77:16
+   |
+LL |     let _val = Some::<usize>([1, 2, 3].iter().sum()).unwrap_or_default();
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `unwrap_or_else()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:78:16
+   |
+LL |     let _val = Some::<usize>([1, 2, 3].iter().sum()).unwrap_or_else(|| 2);
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Some` and `unwrap_or_else()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:78:16
+   |
+LL |     let _val = Some::<usize>([1, 2, 3].iter().sum()).unwrap_or_else(|| 2);
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `unwrap_or()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:81:17
+   |
+LL |     let _val2 = val.unwrap_or(2);
+   |                 ^^^^^^^^^^^^^^^^
+   |
+help: remove the `Some` and `unwrap_or()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:80:15
+   |
+LL |     let val = Some::<usize>([1, 2, 3].iter().sum());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `unwrap_or_default()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:82:17
+   |
+LL |     let _val2 = val.unwrap_or_default();
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Some` and `unwrap_or_default()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:80:15
+   |
+LL |     let val = Some::<usize>([1, 2, 3].iter().sum());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `unwrap_or_else()` on `Some` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:83:17
+   |
+LL |     let _val2 = val.unwrap_or_else(|| 2);
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Some` and `unwrap_or_else()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:80:15
+   |
+LL |     let val = Some::<usize>([1, 2, 3].iter().sum());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `unwrap_or()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:88:17
+   |
+LL |     let _val2 = val.unwrap_or(2);
+   |                 ^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap_or()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:87:15
+   |
+LL |     let val = Ok::<_, ()>(1);
+   |               ^^^^^^^^^^^^^^
+
+error: used `unwrap_or_default()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:89:17
+   |
+LL |     let _val2 = val.unwrap_or_default();
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap_or_default()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:87:15
+   |
+LL |     let val = Ok::<_, ()>(1);
+   |               ^^^^^^^^^^^^^^
+
+error: used `unwrap_or_else()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:90:17
+   |
+LL |     let _val2 = val.unwrap_or_else(|_| 2);
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap_or_else()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:87:15
+   |
+LL |     let val = Ok::<_, ()>(1);
+   |               ^^^^^^^^^^^^^^
+
+error: used `unwrap_or()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:94:16
+   |
+LL |     let _val = Ok::<usize, ()>([1, 2, 3].iter().sum()).unwrap_or(2);
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap_or()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:94:16
+   |
+LL |     let _val = Ok::<usize, ()>([1, 2, 3].iter().sum()).unwrap_or(2);
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `unwrap_or_default()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:95:16
+   |
+LL |     let _val = Ok::<usize, ()>([1, 2, 3].iter().sum()).unwrap_or_default();
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap_or_default()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:95:16
+   |
+LL |     let _val = Ok::<usize, ()>([1, 2, 3].iter().sum()).unwrap_or_default();
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `unwrap_or_else()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:96:16
+   |
+LL |     let _val = Ok::<usize, ()>([1, 2, 3].iter().sum()).unwrap_or_else(|_| 2);
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap_or_else()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:96:16
+   |
+LL |     let _val = Ok::<usize, ()>([1, 2, 3].iter().sum()).unwrap_or_else(|_| 2);
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `unwrap_or()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:99:17
+   |
+LL |     let _val2 = val.unwrap_or(2);
+   |                 ^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap_or()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:98:15
+   |
+LL |     let val = Ok::<usize, ()>([1, 2, 3].iter().sum());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `unwrap_or_default()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:100:17
+   |
+LL |     let _val2 = val.unwrap_or_default();
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap_or_default()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:98:15
+   |
+LL |     let val = Ok::<usize, ()>([1, 2, 3].iter().sum());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: used `unwrap_or_else()` on `Ok` value
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:101:17
+   |
+LL |     let _val2 = val.unwrap_or_else(|_| 2);
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the `Ok` and `unwrap_or_else()`
+  --> $DIR/unnecessary_literal_unwrap_unfixable.rs:98:15
+   |
+LL |     let val = Ok::<usize, ()>([1, 2, 3].iter().sum());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 50 previous errors
+
diff --git a/tests/ui/unwrap.rs b/tests/ui/unwrap.rs
index d9fd402e7cf..64d6437834e 100644
--- a/tests/ui/unwrap.rs
+++ b/tests/ui/unwrap.rs
@@ -1,4 +1,5 @@
 #![warn(clippy::unwrap_used)]
+#![allow(clippy::unnecessary_literal_unwrap)]
 
 fn unwrap_option() {
     let opt = Some(0);
diff --git a/tests/ui/unwrap.stderr b/tests/ui/unwrap.stderr
index d49bf2b3228..3796d942ff9 100644
--- a/tests/ui/unwrap.stderr
+++ b/tests/ui/unwrap.stderr
@@ -1,5 +1,5 @@
 error: used `unwrap()` on an `Option` value
-  --> $DIR/unwrap.rs:5:13
+  --> $DIR/unwrap.rs:6:13
    |
 LL |     let _ = opt.unwrap();
    |             ^^^^^^^^^^^^
@@ -8,7 +8,7 @@ LL |     let _ = opt.unwrap();
    = note: `-D clippy::unwrap-used` implied by `-D warnings`
 
 error: used `unwrap()` on a `Result` value
-  --> $DIR/unwrap.rs:10:13
+  --> $DIR/unwrap.rs:11:13
    |
 LL |     let _ = res.unwrap();
    |             ^^^^^^^^^^^^
@@ -16,7 +16,7 @@ LL |     let _ = res.unwrap();
    = help: if you don't want to handle the `Err` case gracefully, consider using `expect()` to provide a better panic message
 
 error: used `unwrap_err()` on a `Result` value
-  --> $DIR/unwrap.rs:11:13
+  --> $DIR/unwrap.rs:12:13
    |
 LL |     let _ = res.unwrap_err();
    |             ^^^^^^^^^^^^^^^^
diff --git a/tests/ui/unwrap_expect_used.rs b/tests/ui/unwrap_expect_used.rs
index 9f27fef8249..7f57efc53c9 100644
--- a/tests/ui/unwrap_expect_used.rs
+++ b/tests/ui/unwrap_expect_used.rs
@@ -1,4 +1,5 @@
 #![warn(clippy::unwrap_used, clippy::expect_used)]
+#![allow(clippy::unnecessary_literal_unwrap)]
 
 trait OptionExt {
     type Item;
diff --git a/tests/ui/unwrap_expect_used.stderr b/tests/ui/unwrap_expect_used.stderr
index fe4ecef1145..1a551ab5ab8 100644
--- a/tests/ui/unwrap_expect_used.stderr
+++ b/tests/ui/unwrap_expect_used.stderr
@@ -1,5 +1,5 @@
 error: used `unwrap()` on an `Option` value
-  --> $DIR/unwrap_expect_used.rs:23:5
+  --> $DIR/unwrap_expect_used.rs:24:5
    |
 LL |     Some(3).unwrap();
    |     ^^^^^^^^^^^^^^^^
@@ -8,7 +8,7 @@ LL |     Some(3).unwrap();
    = note: `-D clippy::unwrap-used` implied by `-D warnings`
 
 error: used `expect()` on an `Option` value
-  --> $DIR/unwrap_expect_used.rs:24:5
+  --> $DIR/unwrap_expect_used.rs:25:5
    |
 LL |     Some(3).expect("Hello world!");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -17,7 +17,7 @@ LL |     Some(3).expect("Hello world!");
    = note: `-D clippy::expect-used` implied by `-D warnings`
 
 error: used `unwrap()` on a `Result` value
-  --> $DIR/unwrap_expect_used.rs:31:5
+  --> $DIR/unwrap_expect_used.rs:32:5
    |
 LL |     a.unwrap();
    |     ^^^^^^^^^^
@@ -25,7 +25,7 @@ LL |     a.unwrap();
    = help: if this value is an `Err`, it will panic
 
 error: used `expect()` on a `Result` value
-  --> $DIR/unwrap_expect_used.rs:32:5
+  --> $DIR/unwrap_expect_used.rs:33:5
    |
 LL |     a.expect("Hello world!");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -33,7 +33,7 @@ LL |     a.expect("Hello world!");
    = help: if this value is an `Err`, it will panic
 
 error: used `unwrap_err()` on a `Result` value
-  --> $DIR/unwrap_expect_used.rs:33:5
+  --> $DIR/unwrap_expect_used.rs:34:5
    |
 LL |     a.unwrap_err();
    |     ^^^^^^^^^^^^^^
@@ -41,7 +41,7 @@ LL |     a.unwrap_err();
    = help: if this value is an `Ok`, it will panic
 
 error: used `expect_err()` on a `Result` value
-  --> $DIR/unwrap_expect_used.rs:34:5
+  --> $DIR/unwrap_expect_used.rs:35:5
    |
 LL |     a.expect_err("Hello error!");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/unwrap_or.rs b/tests/ui/unwrap_or.rs
index a0c003f5b1e..5bea85e6692 100644
--- a/tests/ui/unwrap_or.rs
+++ b/tests/ui/unwrap_or.rs
@@ -1,4 +1,5 @@
 #![warn(clippy::all, clippy::or_fun_call)]
+#![allow(clippy::unnecessary_literal_unwrap)]
 
 fn main() {
     let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len();
diff --git a/tests/ui/unwrap_or.stderr b/tests/ui/unwrap_or.stderr
index c3a7464fd47..cf720eaaf05 100644
--- a/tests/ui/unwrap_or.stderr
+++ b/tests/ui/unwrap_or.stderr
@@ -1,5 +1,5 @@
 error: use of `unwrap_or` followed by a function call
-  --> $DIR/unwrap_or.rs:4:47
+  --> $DIR/unwrap_or.rs:5:47
    |
 LL |     let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len();
    |                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "Fail".to_string())`
@@ -7,7 +7,7 @@ LL |     let s = Some(String::from("test string")).unwrap_or("Fail".to_string())
    = note: `-D clippy::or-fun-call` implied by `-D warnings`
 
 error: use of `unwrap_or` followed by a function call
-  --> $DIR/unwrap_or.rs:8:47
+  --> $DIR/unwrap_or.rs:9:47
    |
 LL |     let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len();
    |                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "Fail".to_string())`
diff --git a/tests/ui/unwrap_or_else_default.fixed b/tests/ui/unwrap_or_else_default.fixed
index 59a0ca3f192..08b89a18bbb 100644
--- a/tests/ui/unwrap_or_else_default.fixed
+++ b/tests/ui/unwrap_or_else_default.fixed
@@ -2,7 +2,7 @@
 
 #![warn(clippy::unwrap_or_else_default)]
 #![allow(dead_code)]
-#![allow(clippy::unnecessary_wraps)]
+#![allow(clippy::unnecessary_wraps, clippy::unnecessary_literal_unwrap)]
 
 /// Checks implementation of the `UNWRAP_OR_ELSE_DEFAULT` lint.
 fn unwrap_or_else_default() {
diff --git a/tests/ui/unwrap_or_else_default.rs b/tests/ui/unwrap_or_else_default.rs
index 97cafa336ed..ad2a744908f 100644
--- a/tests/ui/unwrap_or_else_default.rs
+++ b/tests/ui/unwrap_or_else_default.rs
@@ -2,7 +2,7 @@
 
 #![warn(clippy::unwrap_or_else_default)]
 #![allow(dead_code)]
-#![allow(clippy::unnecessary_wraps)]
+#![allow(clippy::unnecessary_wraps, clippy::unnecessary_literal_unwrap)]
 
 /// Checks implementation of the `UNWRAP_OR_ELSE_DEFAULT` lint.
 fn unwrap_or_else_default() {