Skip to content

Commit 1531d26

Browse files
committed
Limit scope of the hint about escaping.
1 parent 32be348 commit 1531d26

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

compiler/rustc_interface/src/interface.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,16 @@ pub fn parse_cfgspecs(cfgspecs: Vec<String>) -> FxHashSet<(String, Option<String
124124
Err(errs) => errs.into_iter().for_each(|mut err| err.cancel()),
125125
}
126126

127-
error!(concat!(
128-
r#"expected `key` or `key="value"`, ensure escaping is appropriate"#,
129-
r#" for your shell, try 'key="value"' or key=\"value\""#
130-
));
127+
// If the user tried to use a key="value" flag, but is missing the quotes, provide
128+
// a hint about how to resolve this.
129+
if s.contains("=") && !s.contains("=\"") && !s.ends_with("\"") {
130+
error!(concat!(
131+
r#"expected `key` or `key="value"`, ensure escaping is appropriate"#,
132+
r#" for your shell, try 'key="value"' or key=\"value\""#
133+
));
134+
} else {
135+
error!(r#"expected `key` or `key="value"`"#);
136+
}
131137
})
132138
.collect::<CrateConfig>();
133139
cfg.into_iter().map(|(a, b)| (a.to_string(), b.map(|b| b.to_string()))).collect()

0 commit comments

Comments
 (0)