]> git.lizzy.rs Git - rust.git/blob - tests/ui/single_char_pattern.rs
Merge pull request #2984 from flip1995/single_char_pattern
[rust.git] / tests / ui / single_char_pattern.rs
1 use std::collections::HashSet;
2
3 fn main() {
4     let x = "foo";
5     x.split("x");
6     x.split("xx");
7     x.split('x');
8
9     let y = "x";
10     x.split(y);
11     // Not yet testing for multi-byte characters
12     // Changing `r.len() == 1` to `r.chars().count() == 1` in `lint_single_char_pattern`
13     // should have done this but produced an ICE
14     //
15     // We may not want to suggest changing these anyway
16     // See: https://github.com/rust-lang-nursery/rust-clippy/issues/650#issuecomment-184328984
17     x.split("ß");
18     x.split("ℝ");
19     x.split("💣");
20     // Can't use this lint for unicode code points which don't fit in a char
21     x.split("❤️");
22     x.contains("x");
23     x.starts_with("x");
24     x.ends_with("x");
25     x.find("x");
26     x.rfind("x");
27     x.rsplit("x");
28     x.split_terminator("x");
29     x.rsplit_terminator("x");
30     x.splitn(0, "x");
31     x.rsplitn(0, "x");
32     x.matches("x");
33     x.rmatches("x");
34     x.match_indices("x");
35     x.rmatch_indices("x");
36     x.trim_left_matches("x");
37     x.trim_right_matches("x");
38     // Make sure we escape characters correctly.
39     x.split("\n");
40
41     let h = HashSet::<String>::new();
42     h.contains("X"); // should not warn
43
44     x.replace(";", ",").split(","); // issue #2978
45 }