diff options
| author | GnomedDev <david2005thomas@gmail.com> | 2024-10-05 17:08:33 +0100 |
|---|---|---|
| committer | GnomedDev <david2005thomas@gmail.com> | 2024-10-05 17:10:21 +0100 |
| commit | 196dbcf6d5fa474e9dd15a0bbaad1ced3e0f28fe (patch) | |
| tree | 7a57822b37e9c64e39fbefb47c19b89dc55cfa9b /tests | |
| parent | 9f5bfe24eb254fbe3f745062a4c9ce1c76ff800f (diff) | |
| download | rust-196dbcf6d5fa474e9dd15a0bbaad1ced3e0f28fe.tar.gz rust-196dbcf6d5fa474e9dd15a0bbaad1ced3e0f28fe.zip | |
Avoid linting for Regexes compiled in items defined in loops
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/regex.rs | 2 | ||||
| -rw-r--r-- | tests/ui/regex.stderr | 10 |
2 files changed, 7 insertions, 5 deletions
diff --git a/tests/ui/regex.rs b/tests/ui/regex.rs index 3352239892c..f607a2d50c6 100644 --- a/tests/ui/regex.rs +++ b/tests/ui/regex.rs @@ -120,6 +120,8 @@ fn trivial_regex() { fn regex_creation_in_loops() { loop { + static STATIC_REGEX: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| Regex::new("a.b").unwrap()); + let regex = Regex::new("a.b"); //~^ ERROR: compiling a regex in a loop let regex = BRegex::new("a.b"); diff --git a/tests/ui/regex.stderr b/tests/ui/regex.stderr index 38e14b16316..18dd538c68b 100644 --- a/tests/ui/regex.stderr +++ b/tests/ui/regex.stderr @@ -196,7 +196,7 @@ LL | let binary_trivial_empty = BRegex::new("^$"); = help: consider using `str::is_empty` error: compiling a regex in a loop - --> tests/ui/regex.rs:123:21 + --> tests/ui/regex.rs:125:21 | LL | let regex = Regex::new("a.b"); | ^^^^^^^^^^ @@ -210,7 +210,7 @@ LL | loop { = help: to override `-D warnings` add `#[allow(clippy::regex_creation_in_loops)]` error: compiling a regex in a loop - --> tests/ui/regex.rs:125:21 + --> tests/ui/regex.rs:127:21 | LL | let regex = BRegex::new("a.b"); | ^^^^^^^^^^^ @@ -222,7 +222,7 @@ LL | loop { | ^^^^ error: compiling a regex in a loop - --> tests/ui/regex.rs:131:25 + --> tests/ui/regex.rs:133:25 | LL | let regex = Regex::new("a.b"); | ^^^^^^^^^^ @@ -234,13 +234,13 @@ LL | loop { | ^^^^ error: compiling a regex in a loop - --> tests/ui/regex.rs:136:32 + --> tests/ui/regex.rs:138:32 | LL | let nested_regex = Regex::new("a.b"); | ^^^^^^^^^^ | help: move the regex construction outside this loop - --> tests/ui/regex.rs:135:9 + --> tests/ui/regex.rs:137:9 | LL | for _ in 0..10 { | ^^^^^^^^^^^^^^ |
