Logo
Explore Help
Register Sign In
rust-lang/rust
1
0
Fork 0
You've already forked rust
Code Issues Pull Requests Actions 1 Packages Projects Releases Wiki Activity
Files
b3827e4f3728b77bd3e60587487ebfc3cc8d901b
rust/tests/ui/parser/bad-escape-suggest-raw-string.rs

8 lines
336 B
Rust
Raw Normal View History

suggest using raw string literals when invalid escapes appear 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.
2022-02-14 14:21:43 -05:00
fn main() {
let ok = r"ab\[c";
let bad = "ab\[c";
//~^ ERROR unknown character escape: `[`
Use a better link
2023-06-10 14:46:11 -04:00
//~| HELP for more information, visit <https://doc.rust-lang.org/reference/tokens.html#literals>
suggest using raw string literals when invalid escapes appear 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.
2022-02-14 14:21:43 -05:00
//~| HELP if you meant to write a literal backslash (perhaps escaping in a regular expression), consider a raw string literal
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.24.6 Page: 1648ms Template: 3ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API