summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/string_lit_chars_any.fixed
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
commitd1b2d29528b7794b41e66fc2136e395a02f8529b (patch)
treea4a17504b260206dec3cf55b2dca82929a348ac2 /src/tools/clippy/tests/ui/string_lit_chars_any.fixed
parentReleasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz
rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/clippy/tests/ui/string_lit_chars_any.fixed')
-rw-r--r--src/tools/clippy/tests/ui/string_lit_chars_any.fixed50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/string_lit_chars_any.fixed b/src/tools/clippy/tests/ui/string_lit_chars_any.fixed
new file mode 100644
index 000000000..d7ab9c339
--- /dev/null
+++ b/src/tools/clippy/tests/ui/string_lit_chars_any.fixed
@@ -0,0 +1,50 @@
+//@run-rustfix
+//@aux-build:proc_macros.rs:proc-macro
+#![allow(clippy::eq_op, clippy::needless_raw_string_hashes, clippy::no_effect, unused)]
+#![warn(clippy::string_lit_chars_any)]
+
+#[macro_use]
+extern crate proc_macros;
+
+struct NotStringLit;
+
+impl NotStringLit {
+ fn chars(&self) -> impl Iterator<Item = char> {
+ "c".chars()
+ }
+}
+
+fn main() {
+ let c = 'c';
+ matches!(c, '\\' | '.' | '+' | '*' | '?' | '(' | ')' | '|' | '[' | ']' | '{' | '}' | '^' | '$' | '#' | '&' | '-' | '~');
+ matches!(c, '\\' | '.' | '+' | '*' | '?' | '(' | ')' | '|' | '[' | ']' | '{' | '}' | '^' | '$' | '#' | '&' | '-' | '~');
+ matches!(c, '\\' | '.' | '+' | '*' | '?' | '(' | ')' | '|' | '[' | ']' | '{' | '}' | '^' | '$' | '#' | '&' | '-' | '~');
+ matches!(c, '\\' | '.' | '+' | '*' | '?' | '(' | ')' | '|' | '[' | ']' | '{' | '}' | '^' | '$' | '#' | '&' | '-' | '~');
+ #[rustfmt::skip]
+ matches!(c, '\\' | '.' | '+' | '*' | '?' | '(' | ')' | '|' | '[' | ']' | '{' | '}' | '^' | '$' | '#' | '&' | '-' | '~');
+ // Do not lint
+ NotStringLit.chars().any(|x| x == c);
+ "\\.+*?()|[]{}^$#&-~".chars().any(|x| {
+ let c = 'c';
+ x == c
+ });
+ "\\.+*?()|[]{}^$#&-~".chars().any(|x| {
+ 1;
+ x == c
+ });
+ "\\.+*?()|[]{}^$#&-~".chars().any(|x| x == x);
+ "\\.+*?()|[]{}^$#&-~".chars().any(|_x| c == c);
+ matches!(
+ c,
+ '\\' | '.' | '+' | '*' | '(' | ')' | '|' | '[' | ']' | '{' | '}' | '^' | '$' | '#' | '&' | '-' | '~'
+ );
+ external! {
+ let c = 'c';
+ "\\.+*?()|[]{}^$#&-~".chars().any(|x| x == c);
+ }
+ with_span! {
+ span
+ let c = 'c';
+ "\\.+*?()|[]{}^$#&-~".chars().any(|x| x == c);
+ }
+}