@@ -378,8 +378,8 @@ fn check_exclusive_range_plus_one(cx: &LateContext<'_>, expr: &Expr<'_>) {
378378 span,
379379 "an inclusive range would be more readable" ,
380380 |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 ( ) ;
383383 if let Some ( is_wrapped) = & snippet_opt( cx, span) {
384384 if is_wrapped. starts_with( '(' ) && is_wrapped. ends_with( ')' ) {
385385 diag. span_suggestion(
@@ -415,8 +415,8 @@ fn check_inclusive_range_minus_one(cx: &LateContext<'_>, expr: &Expr<'_>) {
415415 expr. span,
416416 "an exclusive range would be more readable" ,
417417 |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 ( ) ;
420420 diag. span_suggestion(
421421 expr. span,
422422 "use" ,
0 commit comments