Skip to content

Commit 973ae82

Browse files
committed
Merge branch 'pr-942'
2 parents 6a309af + 86a2c94 commit 973ae82

File tree

6 files changed

+99
-104
lines changed

6 files changed

+99
-104
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## 0.0.68 — 2016-05-17
5+
* Rustup to *rustc 1.10.0-nightly (cd6a40017 2016-05-16)*
6+
* New lint: [`unnecessary_operation`]
7+
48
## 0.0.67 — 2016-05-12
59
* Rustup to *rustc 1.10.0-nightly (22ac88f1a 2016-05-11)*
610

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.0.67"
3+
version = "0.0.68"
44
authors = [
55
"Manish Goregaokar <[email protected]>",
66
"Andre Bogus <[email protected]>",

src/len_zero.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItem]) {
126126
}
127127

128128
fn is_self_sig(sig: &MethodSig) -> bool {
129-
if let SelfStatic = sig.explicit_self.node {
130-
false
131-
} else {
129+
if sig.decl.has_self() {
132130
sig.decl.inputs.len() == 1
131+
} else {
132+
false
133133
}
134134
}
135135

src/lifetimes.rs

+8-25
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ impl LintPass for LifetimePass {
4646
impl LateLintPass for LifetimePass {
4747
fn check_item(&mut self, cx: &LateContext, item: &Item) {
4848
if let ItemFn(ref decl, _, _, _, ref generics, _) = item.node {
49-
check_fn_inner(cx, decl, None, generics, item.span);
49+
check_fn_inner(cx, decl, generics, item.span);
5050
}
5151
}
5252

5353
fn check_impl_item(&mut self, cx: &LateContext, item: &ImplItem) {
5454
if let ImplItemKind::Method(ref sig, _) = item.node {
55-
check_fn_inner(cx, &sig.decl, Some(&sig.explicit_self), &sig.generics, item.span);
55+
check_fn_inner(cx, &sig.decl, &sig.generics, item.span);
5656
}
5757
}
5858

5959
fn check_trait_item(&mut self, cx: &LateContext, item: &TraitItem) {
6060
if let MethodTraitItem(ref sig, _) = item.node {
61-
check_fn_inner(cx, &sig.decl, Some(&sig.explicit_self), &sig.generics, item.span);
61+
check_fn_inner(cx, &sig.decl, &sig.generics, item.span);
6262
}
6363
}
6464
}
@@ -87,7 +87,7 @@ fn bound_lifetimes(bound: &TyParamBound) -> Option<HirVec<&Lifetime>> {
8787
}
8888
}
8989

90-
fn check_fn_inner(cx: &LateContext, decl: &FnDecl, slf: Option<&ExplicitSelf>, generics: &Generics, span: Span) {
90+
fn check_fn_inner(cx: &LateContext, decl: &FnDecl, generics: &Generics, span: Span) {
9191
if in_external_macro(cx, span) || has_where_lifetimes(cx, &generics.where_clause) {
9292
return;
9393
}
@@ -96,16 +96,16 @@ fn check_fn_inner(cx: &LateContext, decl: &FnDecl, slf: Option<&ExplicitSelf>, g
9696
.iter()
9797
.flat_map(|ref typ| typ.bounds.iter().filter_map(bound_lifetimes).flat_map(|lts| lts));
9898

99-
if could_use_elision(cx, decl, slf, &generics.lifetimes, bounds_lts) {
99+
if could_use_elision(cx, decl, &generics.lifetimes, bounds_lts) {
100100
span_lint(cx,
101101
NEEDLESS_LIFETIMES,
102102
span,
103103
"explicit lifetimes given in parameter types where they could be elided");
104104
}
105-
report_extra_lifetimes(cx, decl, generics, slf);
105+
report_extra_lifetimes(cx, decl, generics);
106106
}
107107

108-
fn could_use_elision<'a, T: Iterator<Item = &'a Lifetime>>(cx: &LateContext, func: &FnDecl, slf: Option<&ExplicitSelf>,
108+
fn could_use_elision<'a, T: Iterator<Item = &'a Lifetime>>(cx: &LateContext, func: &FnDecl,
109109
named_lts: &[LifetimeDef], bounds_lts: T)
110110
-> bool {
111111
// There are two scenarios where elision works:
@@ -121,15 +121,6 @@ fn could_use_elision<'a, T: Iterator<Item = &'a Lifetime>>(cx: &LateContext, fun
121121
let mut input_visitor = RefVisitor::new(cx);
122122
let mut output_visitor = RefVisitor::new(cx);
123123

124-
// extract lifetime in "self" argument for methods (there is a "self" argument
125-
// in func.inputs, but its type is TyInfer)
126-
if let Some(slf) = slf {
127-
match slf.node {
128-
SelfRegion(ref opt_lt, _, _) => input_visitor.record(opt_lt),
129-
SelfExplicit(ref ty, _) => walk_ty(&mut input_visitor, ty),
130-
_ => (),
131-
}
132-
}
133124
// extract lifetimes in input argument types
134125
for arg in &func.inputs {
135126
input_visitor.visit_ty(&arg.ty);
@@ -340,7 +331,7 @@ impl<'v> Visitor<'v> for LifetimeChecker {
340331
}
341332
}
342333

343-
fn report_extra_lifetimes(cx: &LateContext, func: &FnDecl, generics: &Generics, slf: Option<&ExplicitSelf>) {
334+
fn report_extra_lifetimes(cx: &LateContext, func: &FnDecl, generics: &Generics) {
344335
let hs = generics.lifetimes
345336
.iter()
346337
.map(|lt| (lt.lifetime.name, lt.lifetime.span))
@@ -350,14 +341,6 @@ fn report_extra_lifetimes(cx: &LateContext, func: &FnDecl, generics: &Generics,
350341
walk_generics(&mut checker, generics);
351342
walk_fn_decl(&mut checker, func);
352343

353-
if let Some(slf) = slf {
354-
match slf.node {
355-
SelfRegion(Some(ref lt), _, _) => checker.visit_lifetime(lt),
356-
SelfExplicit(ref t, _) => walk_ty(&mut checker, t),
357-
_ => (),
358-
}
359-
}
360-
361344
for &v in checker.0.values() {
362345
span_lint(cx, UNUSED_LIFETIMES, v, "this lifetime isn't used in the function definition");
363346
}

0 commit comments

Comments
 (0)