-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unrecognized escape sequence #4170
Comments
This indeed looks like valid regex. But Clippy uses the parser of rust-lang/regex to detect invalid regex. This means the regex parser fails to parse what seems to be valid regex. You should probably open an issue in rust-lang/regex. Building a suggestion for this lint is hard or even impossible, since Clippy can't really guess what the correct regex would be. |
I opened an issue there, thanks. |
I found the solution here. The reason it fails is because it should be escaped once for the string literal, and once for the regex. If possible, a better description of the problem would be nice. |
Yeah, I was just about to write this, after testing this. You could also use a raw string: -static ref RE: Regex = Regex::new("^..?($|[\\/])").unwrap();
+static ref RE: Regex = Regex::new(r"^..?($|[\\/])").unwrap(); |
Ok in this case, a (multipart) suggestion would be possible: "Try escaping the "Or use a raw string: |
Hm... I recently had this problem. My solution was to just remove the |
Clippy version:
clippy 0.0.212 (265318d 2019-05-17)
I get the following error when linting code, and I have a feeling it might be a bug. If it is not, it maybe clippy can give a correct suggestion?
The text was updated successfully, but these errors were encountered: