You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The invalid_regex lint incorrectly identifies a valid regular expression involving a unicode general category as invalid, when written as a raw string as the argument to regex::bytes::Regex::new.
Minimal example:
externcrate regex;use regex::bytes::Regex;fnmain(){let re = Regex::new(r"\p{C}").unwrap();let text = "hello world\0";let processed_text = String::from_utf8(re.replace_all(text.as_bytes(),&b""[..]).to_vec()).unwrap();println!("{:?}", processed_text);}
Checking playground v0.0.1 (/playground)
error: regex syntax error: Unicode not allowed here
--> src/main.rs:6:27
|
6 | let re = Regex::new(r"\p{C}").unwrap();
| ^^^^^
|
= note: `#[deny(clippy::invalid_regex)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#invalid_regex
error: aborting due to previous error
Fix unicode regexen with bytes::Regex
fixes#6005
The rationale for this is that since we wrote that lint, `bytes::Regex` was extended to be able to use unicode character classes.
---
changelog: [`invalid_regex`]: allow unicode character classes in bytes regex.
The
invalid_regex
lint incorrectly identifies a valid regular expression involving a unicode general category as invalid, when written as a raw string as the argument toregex::bytes::Regex::new
.Minimal example:
Playground link: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=b4cfb83fe8ffa625e5c5881b05a89dbc
Clippy produces this error:
Clippy seems to be OK with:
regex::Regex
instead ofregex::bytes::Regex
The same regex written as an ordinary stringEDIT: actually this fails in the same way"\\p{C}"
Meta
regex
crate v1.3.9cargo clippy -V
: clippy 0.0.212 (0d0f6b1 2020-09-03)rustc -Vv
:The text was updated successfully, but these errors were encountered: