Skip to content

Commit 1167257

Browse files
committed
Fix unicode regexen with bytes::Regex
fixes #6005
1 parent 2771918 commit 1167257

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

clippy_lints/src/regex.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ fn check_set<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, utf8: bool) {
143143

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

tests/ui/regex.rs

+3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ fn trivial_regex() {
7171
let non_trivial_ends_with = Regex::new("foo|bar");
7272
let non_trivial_binary = BRegex::new("foo|bar");
7373
let non_trivial_binary_builder = BRegexBuilder::new("foo|bar");
74+
75+
// #6005: unicode classes in bytes::Regex
76+
let a_byte_of_unicode = BRegex::new(r"\p{C}");
7477
}
7578

7679
fn main() {

0 commit comments

Comments
 (0)