Added a help span which informs the user about the escaping of curly braces in a format string if a wrongly escaped one is detected in a string.

This commit is contained in:
Manuel Hoffmann
2015-04-13 15:56:10 +02:00
parent 0a2885ad94
commit 4abade50d7
2 changed files with 25 additions and 1 deletions

View File

@@ -843,13 +843,19 @@ impl<'a> StringReader<'a> {
if ascii_only { "unknown byte escape" }
else { "unknown character escape" },
c);
let sp = codemap::mk_sp(escaped_pos, last_pos);
if e == '\r' {
let sp = codemap::mk_sp(escaped_pos, last_pos);
self.span_diagnostic.span_help(
sp,
"this is an isolated carriage return; consider checking \
your editor and version control settings")
}
if (e == '{' || e == '}') && !ascii_only {
self.span_diagnostic.span_help(
sp,
"if used in a formatting string, \
curly braces are escaped with `{{` and `}}`")
}
false
}
}