mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
Add str
to types considered by len_zero
This commit is contained in:
parent
04d81799a2
commit
7eef989ff4
2 changed files with 7 additions and 1 deletions
|
@ -198,7 +198,7 @@ fn has_is_empty(cx: &LateContext, expr: &Expr) -> bool {
|
|||
}
|
||||
ty::TyProjection(_) => ty.ty_to_def_id().map_or(false, |id| has_is_empty_impl(cx, &id)),
|
||||
ty::TyEnum(ref id, _) | ty::TyStruct(ref id, _) => has_is_empty_impl(cx, &id.did),
|
||||
ty::TyArray(..) => true,
|
||||
ty::TyArray(..) | ty::TyStr => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,6 +76,12 @@ fn main() {
|
|||
println!("This should not happen!");
|
||||
}
|
||||
|
||||
if "".len() == 0 {
|
||||
//~^ERROR length comparison to zero
|
||||
//~|HELP consider using `is_empty`
|
||||
//~|SUGGESTION "".is_empty()
|
||||
}
|
||||
|
||||
let y = One;
|
||||
if y.len() == 0 { //no error because One does not have .is_empty()
|
||||
println!("This should not happen either!");
|
||||
|
|
Loading…
Reference in a new issue