mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 07:00:55 +00:00
[case_sensitive_file_extension_comparisons
]: Don't trigger on digits-only extensions
This commit is contained in:
parent
2c3213f5c5
commit
9492de509f
3 changed files with 11 additions and 0 deletions
|
@ -38,6 +38,7 @@ pub(super) fn check<'tcx>(
|
|||
&& ext_str.starts_with('.')
|
||||
&& (ext_str.chars().skip(1).all(|c| c.is_uppercase() || c.is_ascii_digit())
|
||||
|| ext_str.chars().skip(1).all(|c| c.is_lowercase() || c.is_ascii_digit()))
|
||||
&& !ext_str.chars().skip(1).all(|c| c.is_ascii_digit())
|
||||
&& let recv_ty = cx.typeck_results().expr_ty(recv).peel_refs()
|
||||
&& (recv_ty.is_str() || is_type_lang_item(cx, recv_ty, LangItem::String))
|
||||
{
|
||||
|
|
|
@ -63,4 +63,9 @@ fn main() {
|
|||
let _ = String::new().ends_with("a.ext");
|
||||
let _ = "str".ends_with("a.extA");
|
||||
TestStruct {}.ends_with("a.ext");
|
||||
|
||||
// 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");
|
||||
}
|
||||
|
|
|
@ -51,4 +51,9 @@ fn main() {
|
|||
let _ = String::new().ends_with("a.ext");
|
||||
let _ = "str".ends_with("a.extA");
|
||||
TestStruct {}.ends_with("a.ext");
|
||||
|
||||
// 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");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue