Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit c0aa1f7

Browse files
committed
Implement suggestion generation with snippet_with_applicability(.)
1 parent 0409306 commit c0aa1f7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

clippy_lints/src/needless_parens_on_range_literal.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::{
22
diagnostics::span_lint_and_then,
33
higher,
4-
source::{snippet, snippet_opt},
4+
source::{snippet, snippet_with_applicability},
55
};
66

77
use rustc_ast::ast;
@@ -62,12 +62,12 @@ fn check_for_parens(cx: &LateContext<'_>, e: &Expr<'_>, is_start: bool) {
6262
// inspect the source code of the expression for parenthesis
6363
if snippet_enclosed_in_parenthesis(&snippet(cx, e.span, ""));
6464
then {
65+
let mut applicability = Applicability::MachineApplicable;
6566
span_lint_and_then(cx, NEEDLESS_PARENS_ON_RANGE_LITERAL, e.span,
6667
"needless parenthesis on range literal can be removed",
6768
|diag| {
68-
if let Some(suggestion) = snippet_opt(cx, literal.span) {
69-
diag.span_suggestion(e.span, "try", suggestion, Applicability::MachineApplicable);
70-
}
69+
let suggestion = snippet_with_applicability(cx, literal.span, "_", &mut applicability);
70+
diag.span_suggestion(e.span, "try", suggestion, applicability);
7171
});
7272
}
7373
}

0 commit comments

Comments
 (0)