1 #![warn(clippy::case_sensitive_file_extension_comparisons)]
2 
3 use std::string::String;
4 
5 struct TestStruct {}
6 
7 impl TestStruct {
ends_with(self, arg: &str)8     fn ends_with(self, arg: &str) {}
9 }
10 
is_rust_file(filename: &str) -> bool11 fn is_rust_file(filename: &str) -> bool {
12     filename.ends_with(".rs")
13 }
14 
main()15 fn main() {
16     // std::string::String and &str should trigger the lint failure with .ext12
17     let _ = String::from("").ends_with(".ext12");
18     let _ = "str".ends_with(".ext12");
19 
20     // The test struct should not trigger the lint failure with .ext12
21     TestStruct {}.ends_with(".ext12");
22 
23     // std::string::String and &str should trigger the lint failure with .EXT12
24     let _ = String::from("").ends_with(".EXT12");
25     let _ = "str".ends_with(".EXT12");
26 
27     // The test struct should not trigger the lint failure with .EXT12
28     TestStruct {}.ends_with(".EXT12");
29 
30     // Should not trigger the lint failure with .eXT12
31     let _ = String::from("").ends_with(".eXT12");
32     let _ = "str".ends_with(".eXT12");
33     TestStruct {}.ends_with(".eXT12");
34 
35     // Should not trigger the lint failure with .EXT123 (too long)
36     let _ = String::from("").ends_with(".EXT123");
37     let _ = "str".ends_with(".EXT123");
38     TestStruct {}.ends_with(".EXT123");
39 
40     // Shouldn't fail if it doesn't start with a dot
41     let _ = String::from("").ends_with("a.ext");
42     let _ = "str".ends_with("a.extA");
43     TestStruct {}.ends_with("a.ext");
44 }
45