summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/string_lit_chars_any.fixed
blob: d7ab9c3397a1241f04145da8e9254a483ed9409a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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);
    }
}