about summary refs log tree commit diff
diff options
context:
space:
mode:
authorhotate29 <hotate_oc@yahoo.co.jp>2021-12-21 21:45:55 +0900
committerhotate29 <hotate_oc@yahoo.co.jp>2021-12-25 02:24:31 +0900
commita172439f29301d7c34645406f439f064edc58d69 (patch)
tree2f56f0a0e7ddb1270a1754072fbe541a8b2771de
parent07b6927180915ed6a8379c8cc9bec069d13ff0dc (diff)
downloadrust-a172439f29301d7c34645406f439f064edc58d69.tar.gz
rust-a172439f29301d7c34645406f439f064edc58d69.zip
Change to enclose both sides of Range in parentheses.
-rw-r--r--clippy_lints/src/ranges.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/clippy_lints/src/ranges.rs b/clippy_lints/src/ranges.rs
index 09c64485bbb..a1e67c33abf 100644
--- a/clippy_lints/src/ranges.rs
+++ b/clippy_lints/src/ranges.rs
@@ -378,8 +378,8 @@ fn check_exclusive_range_plus_one(cx: &LateContext<'_>, expr: &Expr<'_>) {
                 span,
                 "an inclusive range would be more readable",
                 |diag| {
-                    let start = start.map_or(String::new(), |x| Sugg::hir(cx, x, "x").to_string());
-                    let end = Sugg::hir(cx, y, "y");
+                    let start = start.map_or(String::new(), |x| Sugg::hir(cx, x, "x").maybe_par().to_string());
+                    let end = Sugg::hir(cx, y, "y").maybe_par();
                     if let Some(is_wrapped) = &snippet_opt(cx, span) {
                         if is_wrapped.starts_with('(') && is_wrapped.ends_with(')') {
                             diag.span_suggestion(
@@ -415,8 +415,8 @@ fn check_inclusive_range_minus_one(cx: &LateContext<'_>, expr: &Expr<'_>) {
                 expr.span,
                 "an exclusive range would be more readable",
                 |diag| {
-                    let start = start.map_or(String::new(), |x| Sugg::hir(cx, x, "x").to_string());
-                    let end = Sugg::hir(cx, y, "y");
+                    let start = start.map_or(String::new(), |x| Sugg::hir(cx, x, "x").maybe_par().to_string());
+                    let end = Sugg::hir(cx, y, "y").maybe_par();
                     diag.span_suggestion(
                         expr.span,
                         "use",