mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-26 22:50:56 +00:00
fix ice in len_zero
lint when type has no inherent impls at all
fixes #1336
This commit is contained in:
parent
2cfe1e7b64
commit
cfae1e9fda
2 changed files with 19 additions and 2 deletions
|
@ -194,11 +194,11 @@ fn has_is_empty(cx: &LateContext, expr: &Expr) -> bool {
|
|||
|
||||
/// Check the inherent impl's items for an `is_empty(self)` method.
|
||||
fn has_is_empty_impl(cx: &LateContext, id: DefId) -> bool {
|
||||
cx.tcx.inherent_impls.borrow()[&id].iter().any(|imp| {
|
||||
cx.tcx.inherent_impls.borrow().get(&id).map_or(false, |impls| impls.iter().any(|imp| {
|
||||
cx.tcx.impl_or_trait_items(*imp).iter().any(|item| {
|
||||
is_is_empty(&cx.tcx.impl_or_trait_item(*item))
|
||||
})
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
let ty = &walk_ptrs_ty(cx.tcx.expr_ty(expr));
|
||||
|
|
17
tests/ice_exacte_size.rs
Normal file
17
tests/ice_exacte_size.rs
Normal file
|
@ -0,0 +1,17 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
#![deny(clippy)]
|
||||
|
||||
#[allow(dead_code)]
|
||||
struct Foo;
|
||||
|
||||
impl Iterator for Foo {
|
||||
type Item = ();
|
||||
|
||||
fn next(&mut self) -> Option<()> {
|
||||
let _ = self.len() == 0;
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl ExactSizeIterator for Foo { }
|
Loading…
Reference in a new issue