about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-10-08 08:48:12 +0000
committerbors <bors@rust-lang.org>2020-10-08 08:48:12 +0000
commit171ab9bf9f55fefd4905f2100154228e90da3bf4 (patch)
treee32d7d6ab5f92af4c65377dbaf741f43213b0167
parent13a80b34baab0576e07eaa986d68a355cb1637a9 (diff)
parent11672577debb4880edb5641c470c78175b121bcb (diff)
Auto merge of #6132 - rust-lang:regex-unicode, r=ebroto
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.
-rw-r--r--clippy_lints/src/regex.rs2
-rw-r--r--tests/ui/regex.rs3
2 files changed, 4 insertions, 1 deletions
diff --git a/clippy_lints/src/regex.rs b/clippy_lints/src/regex.rs
index dfc158661cb..95594e38c9e 100644
--- a/clippy_lints/src/regex.rs
+++ b/clippy_lints/src/regex.rs
@@ -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();
 
diff --git a/tests/ui/regex.rs b/tests/ui/regex.rs
index 9767e5bf76a..f7f3b195ccc 100644
--- a/tests/ui/regex.rs
+++ b/tests/ui/regex.rs
@@ -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() {