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