Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Change Log
All notable changes to this project will be documented in this file.

## 0.0.100 — 2016-11-20
* Update to *rustc 1.15.0-nightly (ac635aa95 2016-11-18)*

## 0.0.99 — 2016-11-18
* Update to rustc 1.15.0-nightly (0ed951993 2016-11-14)

Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "clippy"
version = "0.0.99"
version = "0.0.100"
authors = [
"Manish Goregaokar <[email protected]>",
"Andre Bogus <[email protected]>",
Expand All @@ -25,7 +25,7 @@ test = false

[dependencies]
# begin automatic update
clippy_lints = { version = "0.0.99", path = "clippy_lints" }
clippy_lints = { version = "0.0.100", path = "clippy_lints" }
# end automatic update

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "clippy_lints"
# begin automatic update
version = "0.0.99"
version = "0.0.100"
# end automatic update
authors = [
"Manish Goregaokar <[email protected]>",
Expand Down
34 changes: 17 additions & 17 deletions clippy_lints/src/len_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ fn check_trait_items(cx: &LateContext, item: &Item, trait_items: &[TraitItem]) {
fn is_named_self(item: &TraitItem, name: &str) -> bool {
item.name.as_str() == name &&
if let MethodTraitItem(ref sig, _) = item.node {
is_self_sig(sig)
if sig.decl.has_self() {
sig.decl.inputs.len() == 1
} else {
false
}
} else {
false
}
Expand All @@ -111,18 +115,22 @@ fn check_trait_items(cx: &LateContext, item: &Item, trait_items: &[TraitItem]) {
}
}

fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItem]) {
fn is_named_self(item: &ImplItem, name: &str) -> bool {
fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItemRef]) {
fn is_named_self(cx: &LateContext, item: &ImplItemRef, name: &str) -> bool {
item.name.as_str() == name &&
if let ImplItemKind::Method(ref sig, _) = item.node {
is_self_sig(sig)
if let AssociatedItemKind::Method { has_self } = item.kind {
has_self && {
let did = cx.tcx.map.local_def_id(item.id.node_id);
let impl_ty = cx.tcx.item_type(did);
impl_ty.fn_args().skip_binder().len() == 1
}
} else {
false
}
}

let is_empty = if let Some(is_empty) = impl_items.iter().find(|i| is_named_self(i, "is_empty")) {
if cx.access_levels.is_exported(is_empty.id) {
let is_empty = if let Some(is_empty) = impl_items.iter().find(|i| is_named_self(cx, i, "is_empty")) {
if cx.access_levels.is_exported(is_empty.id.node_id) {
return;
} else {
"a private"
Expand All @@ -131,8 +139,8 @@ fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItem]) {
"no corresponding"
};

if let Some(i) = impl_items.iter().find(|i| is_named_self(i, "len")) {
if cx.access_levels.is_exported(i.id) {
if let Some(i) = impl_items.iter().find(|i| is_named_self(cx, i, "len")) {
if cx.access_levels.is_exported(i.id.node_id) {
let def_id = cx.tcx.map.local_def_id(item.id);
let ty = cx.tcx.item_type(def_id);

Expand All @@ -146,14 +154,6 @@ fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItem]) {
}
}

fn is_self_sig(sig: &MethodSig) -> bool {
if sig.decl.has_self() {
sig.decl.inputs.len() == 1
} else {
false
}
}

fn check_cmp(cx: &LateContext, span: Span, left: &Expr, right: &Expr, op: &str) {
// check if we are in an is_empty() method
if let Some(name) = get_item_name(cx, left) {
Expand Down