-
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
invalid_regex
: Show full error when string value doesn't match source
#10231
Conversation
r? @llogiq (rustbot has picked a reviewer for you, use r? to override) |
error: regex parse error: | ||
/b/c | ||
^^ | ||
error: unrecognized escape sequence | ||
--> $DIR/regex.rs:40:42 | ||
| | ||
LL | let escaped_string_span = Regex::new("/b/c"); | ||
| ^^^^^^^^ | ||
| | ||
= help: consider using a raw string literal: `r".."` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compiletest is doing its windows path normalisation thing, it looks like this normally:
error: regex parse error:
\b\c
^^
error: unrecognized escape sequence
--> ../t.rs:6:42
|
6 | let escaped_string_span = Regex::new("\\b\\c");
| ^^^^^^^^
|
= help: consider using a raw string literal: `r".."`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the missing quotation marks when linting a const
, this looks good to me. Let me know if you want to tackle this as part of this PR or if you want to leave it for a followup.
@bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
changelog: [
invalid_regex
]: Show full error when parsing non-literals or regular strings containing escape sequencesFixes #4170, the escape sequence there causes the span to be incorrect which will have caused most of the confusion