-
Notifications
You must be signed in to change notification settings - Fork 1.7k
invalid_regex
: Show full error when string value doesn't match source
#10231
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,10 @@ error: regex syntax error: invalid character class range, the start must be <= t | |
LL | let some_unicode = Regex::new("[é-è]"); | ||
| ^^^ | ||
|
||
error: regex syntax error on position 0: unclosed group | ||
error: regex parse error: | ||
( | ||
^ | ||
error: unclosed group | ||
--> $DIR/regex.rs:18:33 | ||
| | ||
LL | let some_regex = Regex::new(OPENING_PAREN); | ||
|
@@ -43,25 +46,37 @@ LL | let binary_pipe_in_wrong_position = BRegex::new("|"); | |
| | ||
= help: the regex is unlikely to be useful as it is | ||
|
||
error: regex syntax error on position 0: unclosed group | ||
error: regex parse error: | ||
( | ||
^ | ||
error: unclosed group | ||
--> $DIR/regex.rs:21:41 | ||
| | ||
LL | let some_binary_regex = BRegex::new(OPENING_PAREN); | ||
| ^^^^^^^^^^^^^ | ||
|
||
error: regex syntax error on position 0: unclosed group | ||
error: regex parse error: | ||
( | ||
^ | ||
error: unclosed group | ||
--> $DIR/regex.rs:22:56 | ||
| | ||
LL | let some_binary_regex_builder = BRegexBuilder::new(OPENING_PAREN); | ||
| ^^^^^^^^^^^^^ | ||
|
||
error: regex syntax error on position 0: unclosed group | ||
error: regex parse error: | ||
( | ||
^ | ||
error: unclosed group | ||
--> $DIR/regex.rs:34:37 | ||
| | ||
LL | let set_error = RegexSet::new(&[OPENING_PAREN, r"[a-z]+/.(com|org|net)"]); | ||
| ^^^^^^^^^^^^^ | ||
|
||
error: regex syntax error on position 0: unclosed group | ||
error: regex parse error: | ||
( | ||
^ | ||
error: unclosed group | ||
--> $DIR/regex.rs:35:39 | ||
| | ||
LL | let bset_error = BRegexSet::new(&[OPENING_PAREN, r"[a-z]+/.(com|org|net)"]); | ||
|
@@ -79,93 +94,110 @@ error: regex syntax error: unrecognized escape sequence | |
LL | let raw_string_error = Regex::new(r#"[...//...]"#); | ||
| ^^ | ||
|
||
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".."` | ||
Comment on lines
+97
to
+106
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 syntax error: duplicate flag | ||
--> $DIR/regex.rs:42:34 | ||
| | ||
LL | let aux_span = Regex::new("(?ixi)"); | ||
| ^ ^ | ||
|
||
error: trivial regex | ||
--> $DIR/regex.rs:42:33 | ||
--> $DIR/regex.rs:46:33 | ||
| | ||
LL | let trivial_eq = Regex::new("^foobar$"); | ||
| ^^^^^^^^^^ | ||
| | ||
= help: consider using `==` on `str`s | ||
|
||
error: trivial regex | ||
--> $DIR/regex.rs:44:48 | ||
--> $DIR/regex.rs:48:48 | ||
| | ||
LL | let trivial_eq_builder = RegexBuilder::new("^foobar$"); | ||
| ^^^^^^^^^^ | ||
| | ||
= help: consider using `==` on `str`s | ||
|
||
error: trivial regex | ||
--> $DIR/regex.rs:46:42 | ||
--> $DIR/regex.rs:50:42 | ||
| | ||
LL | let trivial_starts_with = Regex::new("^foobar"); | ||
| ^^^^^^^^^ | ||
| | ||
= help: consider using `str::starts_with` | ||
|
||
error: trivial regex | ||
--> $DIR/regex.rs:48:40 | ||
--> $DIR/regex.rs:52:40 | ||
| | ||
LL | let trivial_ends_with = Regex::new("foobar$"); | ||
| ^^^^^^^^^ | ||
| | ||
= help: consider using `str::ends_with` | ||
|
||
error: trivial regex | ||
--> $DIR/regex.rs:50:39 | ||
--> $DIR/regex.rs:54:39 | ||
| | ||
LL | let trivial_contains = Regex::new("foobar"); | ||
| ^^^^^^^^ | ||
| | ||
= help: consider using `str::contains` | ||
|
||
error: trivial regex | ||
--> $DIR/regex.rs:52:39 | ||
--> $DIR/regex.rs:56:39 | ||
| | ||
LL | let trivial_contains = Regex::new(NOT_A_REAL_REGEX); | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
= help: consider using `str::contains` | ||
|
||
error: trivial regex | ||
--> $DIR/regex.rs:54:40 | ||
--> $DIR/regex.rs:58:40 | ||
| | ||
LL | let trivial_backslash = Regex::new("a/.b"); | ||
| ^^^^^^^ | ||
| | ||
= help: consider using `str::contains` | ||
|
||
error: trivial regex | ||
--> $DIR/regex.rs:57:36 | ||
--> $DIR/regex.rs:61:36 | ||
| | ||
LL | let trivial_empty = Regex::new(""); | ||
| ^^ | ||
| | ||
= help: the regex is unlikely to be useful as it is | ||
|
||
error: trivial regex | ||
--> $DIR/regex.rs:59:36 | ||
--> $DIR/regex.rs:63:36 | ||
| | ||
LL | let trivial_empty = Regex::new("^"); | ||
| ^^^ | ||
| | ||
= help: the regex is unlikely to be useful as it is | ||
|
||
error: trivial regex | ||
--> $DIR/regex.rs:61:36 | ||
--> $DIR/regex.rs:65:36 | ||
| | ||
LL | let trivial_empty = Regex::new("^$"); | ||
| ^^^^ | ||
| | ||
= help: consider using `str::is_empty` | ||
|
||
error: trivial regex | ||
--> $DIR/regex.rs:63:44 | ||
--> $DIR/regex.rs:67:44 | ||
| | ||
LL | let binary_trivial_empty = BRegex::new("^$"); | ||
| ^^^^ | ||
| | ||
= help: consider using `str::is_empty` | ||
|
||
error: aborting due to 23 previous errors | ||
error: aborting due to 25 previous errors | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.