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/diagnostics/check_cfg.rs5
1 files changed, 2 insertions, 3 deletions
diff --git a/compiler/rustc_lint/src/context/diagnostics/check_cfg.rs b/compiler/rustc_lint/src/context/diagnostics/check_cfg.rs
index 6f5bf4e5a1d..3fa04ab75f8 100644
--- a/compiler/rustc_lint/src/context/diagnostics/check_cfg.rs
+++ b/compiler/rustc_lint/src/context/diagnostics/check_cfg.rs
@@ -48,10 +48,9 @@ enum EscapeQuotes {
 
 fn to_check_cfg_arg(name: Symbol, value: Option<Symbol>, quotes: EscapeQuotes) -> String {
     if let Some(value) = value {
+        let value = str::escape_debug(value.as_str()).to_string();
         let values = match quotes {
-            EscapeQuotes::Yes => {
-                format!("\\\"{}\\\"", str::escape_debug(value.as_str()).to_string())
-            }
+            EscapeQuotes::Yes => format!("\\\"{}\\\"", value.replace("\"", "\\\\\\\\\"")),
             EscapeQuotes::No => format!("\"{value}\""),
         };
         format!("cfg({name}, values({values}))")