]> git.lizzy.rs Git - rust.git/blob - tests/ui/starts_ends_with.fixed
Auto merge of #8374 - Alexendoo:bless-revisions, r=camsteffen
[rust.git] / tests / ui / starts_ends_with.fixed
1 // run-rustfix
2 #![allow(dead_code, unused_must_use)]
3
4 fn main() {}
5
6 #[allow(clippy::unnecessary_operation)]
7 fn starts_with() {
8     "".starts_with(' ');
9     !"".starts_with(' ');
10
11     // Ensure that suggestion is escaped correctly
12     "".starts_with('\n');
13     !"".starts_with('\n');
14 }
15
16 fn chars_cmp_with_unwrap() {
17     let s = String::from("foo");
18     if s.starts_with('f') {
19         // s.starts_with('f')
20         // Nothing here
21     }
22     if s.ends_with('o') {
23         // s.ends_with('o')
24         // Nothing here
25     }
26     if s.ends_with('o') {
27         // s.ends_with('o')
28         // Nothing here
29     }
30     if !s.starts_with('f') {
31         // !s.starts_with('f')
32         // Nothing here
33     }
34     if !s.ends_with('o') {
35         // !s.ends_with('o')
36         // Nothing here
37     }
38     if !s.ends_with('\n') {
39         // !s.ends_with('o')
40         // Nothing here
41     }
42 }
43
44 #[allow(clippy::unnecessary_operation)]
45 fn ends_with() {
46     "".ends_with(' ');
47     !"".ends_with(' ');
48     "".ends_with(' ');
49     !"".ends_with(' ');
50
51     // Ensure that suggestion is escaped correctly
52     "".ends_with('\n');
53     !"".ends_with('\n');
54 }