@@ -378,8 +378,8 @@ fn check_exclusive_range_plus_one(cx: &LateContext<'_>, expr: &Expr<'_>) {
378
378
span,
379
379
"an inclusive range would be more readable" ,
380
380
|diag| {
381
- let start = start. map_or( String :: new( ) , |x| Sugg :: hir( cx, x, "x" ) . to_string( ) ) ;
382
- let end = Sugg :: hir( cx, y, "y" ) ;
381
+ let start = start. map_or( String :: new( ) , |x| Sugg :: hir( cx, x, "x" ) . maybe_par ( ) . to_string( ) ) ;
382
+ let end = Sugg :: hir( cx, y, "y" ) . maybe_par ( ) ;
383
383
if let Some ( is_wrapped) = & snippet_opt( cx, span) {
384
384
if is_wrapped. starts_with( '(' ) && is_wrapped. ends_with( ')' ) {
385
385
diag. span_suggestion(
@@ -415,8 +415,8 @@ fn check_inclusive_range_minus_one(cx: &LateContext<'_>, expr: &Expr<'_>) {
415
415
expr. span,
416
416
"an exclusive range would be more readable" ,
417
417
|diag| {
418
- let start = start. map_or( String :: new( ) , |x| Sugg :: hir( cx, x, "x" ) . to_string( ) ) ;
419
- let end = Sugg :: hir( cx, y, "y" ) ;
418
+ let start = start. map_or( String :: new( ) , |x| Sugg :: hir( cx, x, "x" ) . maybe_par ( ) . to_string( ) ) ;
419
+ let end = Sugg :: hir( cx, y, "y" ) . maybe_par ( ) ;
420
420
diag. span_suggestion(
421
421
expr. span,
422
422
"use" ,
0 commit comments