i'd guess about 70% of "bad escape" cases occur when someone meant to use a raw string literal because they're passing it directly to Regex::new(). this emits an advisory (Applicability::MaybeIncorrect) help: suggestion to the user that they use an r"" string, on top of the normal notes about looking at the string literal documentation/spec.
7 lines
343 B
Rust
7 lines
343 B
Rust
fn main() {
|
|
let ok = r"ab\[c";
|
|
let bad = "ab\[c";
|
|
//~^ ERROR unknown character escape: `[`
|
|
//~| HELP for more information, visit <https://static.rust-lang.org/doc/master/reference.html#literals>
|
|
//~| HELP if you meant to write a literal backslash (perhaps escaping in a regular expression), consider a raw string literal
|
|
}
|