2020-12-23 05:37:37 -06:00
|
|
|
#![warn(clippy::case_sensitive_file_extension_comparisons)]
|
|
|
|
|
|
|
|
use std::string::String;
|
|
|
|
|
2022-03-27 07:41:09 -05:00
|
|
|
struct TestStruct;
|
2020-12-23 05:37:37 -06:00
|
|
|
|
|
|
|
impl TestStruct {
|
2022-12-21 13:47:39 -06:00
|
|
|
fn ends_with(self, _arg: &str) {}
|
2020-12-23 05:37:37 -06:00
|
|
|
}
|
|
|
|
|
2022-12-21 13:47:39 -06:00
|
|
|
#[allow(dead_code)]
|
2020-12-23 05:37:37 -06:00
|
|
|
fn is_rust_file(filename: &str) -> bool {
|
|
|
|
filename.ends_with(".rs")
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// std::string::String and &str should trigger the lint failure with .ext12
|
2022-08-05 18:59:50 -05:00
|
|
|
let _ = String::new().ends_with(".ext12");
|
2020-12-23 05:37:37 -06:00
|
|
|
let _ = "str".ends_with(".ext12");
|
|
|
|
|
2023-01-04 08:06:07 -06:00
|
|
|
// The fixup should preserve the indentation level
|
|
|
|
{
|
|
|
|
let _ = "str".ends_with(".ext12");
|
|
|
|
}
|
|
|
|
|
2020-12-23 05:37:37 -06:00
|
|
|
// The test struct should not trigger the lint failure with .ext12
|
|
|
|
TestStruct {}.ends_with(".ext12");
|
|
|
|
|
|
|
|
// std::string::String and &str should trigger the lint failure with .EXT12
|
2022-08-05 18:59:50 -05:00
|
|
|
let _ = String::new().ends_with(".EXT12");
|
2020-12-23 05:37:37 -06:00
|
|
|
let _ = "str".ends_with(".EXT12");
|
|
|
|
|
2023-01-02 17:42:56 -06:00
|
|
|
// Should not trigger the lint failure because of the calls to to_lowercase and to_uppercase
|
2022-12-21 13:47:39 -06:00
|
|
|
let _ = String::new().to_lowercase().ends_with(".EXT12");
|
|
|
|
let _ = String::new().to_uppercase().ends_with(".EXT12");
|
|
|
|
|
2020-12-23 05:37:37 -06:00
|
|
|
// The test struct should not trigger the lint failure with .EXT12
|
|
|
|
TestStruct {}.ends_with(".EXT12");
|
|
|
|
|
|
|
|
// Should not trigger the lint failure with .eXT12
|
2022-08-05 18:59:50 -05:00
|
|
|
let _ = String::new().ends_with(".eXT12");
|
2020-12-23 05:37:37 -06:00
|
|
|
let _ = "str".ends_with(".eXT12");
|
|
|
|
TestStruct {}.ends_with(".eXT12");
|
|
|
|
|
|
|
|
// Should not trigger the lint failure with .EXT123 (too long)
|
2022-08-05 18:59:50 -05:00
|
|
|
let _ = String::new().ends_with(".EXT123");
|
2020-12-23 05:37:37 -06:00
|
|
|
let _ = "str".ends_with(".EXT123");
|
|
|
|
TestStruct {}.ends_with(".EXT123");
|
|
|
|
|
|
|
|
// Shouldn't fail if it doesn't start with a dot
|
2022-08-05 18:59:50 -05:00
|
|
|
let _ = String::new().ends_with("a.ext");
|
2020-12-23 05:37:37 -06:00
|
|
|
let _ = "str".ends_with("a.extA");
|
|
|
|
TestStruct {}.ends_with("a.ext");
|
2024-02-14 11:26:06 -06:00
|
|
|
|
|
|
|
// Shouldn't fail if the extension has no ascii letter
|
|
|
|
let _ = String::new().ends_with(".123");
|
|
|
|
let _ = "str".ends_with(".123");
|
|
|
|
TestStruct {}.ends_with(".123");
|
2020-12-23 05:37:37 -06:00
|
|
|
}
|