about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_lint/src/context.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs
index a20ceacdd3a..4a646013ff8 100644
--- a/compiler/rustc_lint/src/context.rs
+++ b/compiler/rustc_lint/src/context.rs
@@ -751,9 +751,12 @@ pub trait LintContext: Sized {
                     }
                 }
                 BuiltinLintDiagnostics::BreakWithLabelAndLoop(span) => {
-                    if let Ok(code) = sess.source_map().span_to_snippet(span) {
-                        db.span_suggestion(span, "wrap this expression in parentheses", format!("({})", &code), Applicability::MachineApplicable);
-                    }
+                    db.multipart_suggestion(
+                        "wrap this expression in parentheses",
+                        vec![(span.shrink_to_lo(), "(".to_string()),
+                             (span.shrink_to_hi(), ")".to_string())],
+                        Applicability::MachineApplicable
+                    );
                 }
             }
             // Rewrap `db`, and pass control to the user.