Skip to content

Commit

Permalink
Auto merge of #6132 - rust-lang:regex-unicode, r=ebroto
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Oct 8, 2020
2 parents 13a80b3 + 1167257 commit 171ab9b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clippy_lints/src/regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ fn check_set<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, utf8: bool) {

fn check_regex<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, utf8: bool) {
let mut parser = regex_syntax::ParserBuilder::new()
.unicode(utf8)
.unicode(true)
.allow_invalid_utf8(!utf8)
.build();

Expand Down
3 changes: 3 additions & 0 deletions tests/ui/regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ fn trivial_regex() {
let non_trivial_ends_with = Regex::new("foo|bar");
let non_trivial_binary = BRegex::new("foo|bar");
let non_trivial_binary_builder = BRegexBuilder::new("foo|bar");

// #6005: unicode classes in bytes::Regex
let a_byte_of_unicode = BRegex::new(r"\p{C}");
}

fn main() {
Expand Down

0 comments on commit 171ab9b

Please sign in to comment.