about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDennis Luxen <info@project-osrm.org>2022-06-04 22:08:33 +0200
committerDennis Luxen <info@project-osrm.org>2022-06-05 22:47:01 +0200
commitc0aa1f78b488e0c99441bd19cb31001d1daab8cf (patch)
tree7a9f28524a9acf1a782d86c01b04b4f526f7dcd4
parent0409306bb02a73d9299410b42c9cd774a216090b (diff)
downloadrust-c0aa1f78b488e0c99441bd19cb31001d1daab8cf.tar.gz
rust-c0aa1f78b488e0c99441bd19cb31001d1daab8cf.zip
Implement suggestion generation with snippet_with_applicability(.)
-rw-r--r--clippy_lints/src/needless_parens_on_range_literal.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/clippy_lints/src/needless_parens_on_range_literal.rs b/clippy_lints/src/needless_parens_on_range_literal.rs
index 1979810f7c4..89cb015b7d4 100644
--- a/clippy_lints/src/needless_parens_on_range_literal.rs
+++ b/clippy_lints/src/needless_parens_on_range_literal.rs
@@ -1,7 +1,7 @@
 use clippy_utils::{
     diagnostics::span_lint_and_then,
     higher,
-    source::{snippet, snippet_opt},
+    source::{snippet, snippet_with_applicability},
 };
 
 use rustc_ast::ast;
@@ -62,12 +62,12 @@ fn check_for_parens(cx: &LateContext<'_>, e: &Expr<'_>, is_start: bool) {
         // inspect the source code of the expression for parenthesis
         if snippet_enclosed_in_parenthesis(&snippet(cx, e.span, ""));
         then {
+            let mut applicability = Applicability::MachineApplicable;
             span_lint_and_then(cx, NEEDLESS_PARENS_ON_RANGE_LITERAL, e.span,
                 "needless parenthesis on range literal can be removed",
                 |diag| {
-                        if let Some(suggestion) = snippet_opt(cx, literal.span) {
-                        diag.span_suggestion(e.span, "try", suggestion, Applicability::MachineApplicable);
-                    }
+                    let suggestion = snippet_with_applicability(cx, literal.span, "_", &mut applicability);
+                    diag.span_suggestion(e.span, "try", suggestion, applicability);
                 });
         }
     }