Skip to content

Commit 4daa4e3

Browse files
authored
Merge pull request #2289 from rust-lang-nursery/rustup
Rustup to rustc 1.24.0-nightly (250b492 2017-12-21)
2 parents ebcdf03 + fae8a76 commit 4daa4e3

File tree

8 files changed

+39
-33
lines changed

8 files changed

+39
-33
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
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.177
5+
* Rustup to *rustc 1.24.0-nightly (250b49205 2017-12-21)*
6+
* New lint: [`match_as_ref`]
7+
48
## 0.0.176
59
* Rustup to *rustc 1.24.0-nightly (0077d128d 2017-12-14)*
610

@@ -595,6 +599,7 @@ All notable changes to this project will be documented in this file.
595599
[`many_single_char_names`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#many_single_char_names
596600
[`map_clone`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#map_clone
597601
[`map_entry`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#map_entry
602+
[`match_as_ref`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#match_as_ref
598603
[`match_bool`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#match_bool
599604
[`match_overlapping_arm`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#match_overlapping_arm
600605
[`match_ref_pats`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#match_ref_pats

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.0.176"
3+
version = "0.0.177"
44
authors = [
55
"Manish Goregaokar <[email protected]>",
66
"Andre Bogus <[email protected]>",
@@ -37,7 +37,7 @@ path = "src/driver.rs"
3737

3838
[dependencies]
3939
# begin automatic update
40-
clippy_lints = { version = "0.0.176", path = "clippy_lints" }
40+
clippy_lints = { version = "0.0.177", path = "clippy_lints" }
4141
# end automatic update
4242
cargo_metadata = "0.2"
4343
regex = "0.2"

clippy_lints/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "clippy_lints"
33
# begin automatic update
4-
version = "0.0.176"
4+
version = "0.0.177"
55
# end automatic update
66
authors = [
77
"Manish Goregaokar <[email protected]>",

clippy_lints/src/lifetimes.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use reexport::*;
22
use rustc::lint::*;
33
use rustc::hir::def::Def;
44
use rustc::hir::*;
5-
use rustc::hir::intravisit::{walk_fn_decl, walk_generics, walk_ty, walk_ty_param_bound, NestedVisitorMap, Visitor};
5+
use rustc::hir::intravisit::*;
66
use std::collections::{HashMap, HashSet};
77
use syntax::codemap::Span;
88
use utils::{in_external_macro, last_path_segment, span_lint};
@@ -101,7 +101,7 @@ fn check_fn_inner<'a, 'tcx>(
101101
}
102102

103103
let mut bounds_lts = Vec::new();
104-
for typ in &generics.ty_params {
104+
for typ in generics.ty_params() {
105105
for bound in &typ.bounds {
106106
if let TraitTyParamBound(ref trait_ref, _) = *bound {
107107
let params = &trait_ref
@@ -122,7 +122,7 @@ fn check_fn_inner<'a, 'tcx>(
122122
}
123123
}
124124
}
125-
if could_use_elision(cx, decl, body, &generics.lifetimes, bounds_lts) {
125+
if could_use_elision(cx, decl, body, &generics.params, bounds_lts) {
126126
span_lint(
127127
cx,
128128
NEEDLESS_LIFETIMES,
@@ -137,7 +137,7 @@ fn could_use_elision<'a, 'tcx: 'a>(
137137
cx: &LateContext<'a, 'tcx>,
138138
func: &'tcx FnDecl,
139139
body: Option<BodyId>,
140-
named_lts: &'tcx [LifetimeDef],
140+
named_generics: &'tcx [GenericParam],
141141
bounds_lts: Vec<&'tcx Lifetime>,
142142
) -> bool {
143143
// There are two scenarios where elision works:
@@ -147,7 +147,7 @@ fn could_use_elision<'a, 'tcx: 'a>(
147147
// level of the current item.
148148

149149
// check named LTs
150-
let allowed_lts = allowed_lts_from(named_lts);
150+
let allowed_lts = allowed_lts_from(named_generics);
151151

152152
// these will collect all the lifetimes for references in arg/return types
153153
let mut input_visitor = RefVisitor::new(cx);
@@ -222,11 +222,13 @@ fn could_use_elision<'a, 'tcx: 'a>(
222222
}
223223
}
224224

225-
fn allowed_lts_from(named_lts: &[LifetimeDef]) -> HashSet<RefLt> {
225+
fn allowed_lts_from(named_generics: &[GenericParam]) -> HashSet<RefLt> {
226226
let mut allowed_lts = HashSet::new();
227-
for lt in named_lts {
228-
if lt.bounds.is_empty() {
229-
allowed_lts.insert(RefLt::Named(lt.lifetime.name.name()));
227+
for par in named_generics.iter() {
228+
if let GenericParam::Lifetime(ref lt) = *par {
229+
if lt.bounds.is_empty() {
230+
allowed_lts.insert(RefLt::Named(lt.lifetime.name.name()));
231+
}
230232
}
231233
}
232234
allowed_lts.insert(RefLt::Unnamed);
@@ -332,11 +334,6 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
332334
}
333335
}
334336
}
335-
TyImplTraitUniversal(_, ref param_bounds) => for bound in param_bounds {
336-
if let RegionTyParamBound(_) = *bound {
337-
self.record(&None);
338-
}
339-
},
340337
TyTraitObject(ref bounds, ref lt) => {
341338
if !lt.is_elided() {
342339
self.abort = true;
@@ -370,7 +367,7 @@ fn has_where_lifetimes<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, where_clause: &
370367
return true;
371368
}
372369
// if the bounds define new lifetimes, they are fine to occur
373-
let allowed_lts = allowed_lts_from(&pred.bound_lifetimes);
370+
let allowed_lts = allowed_lts_from(&pred.bound_generic_params);
374371
// now walk the bounds
375372
for bound in pred.bounds.iter() {
376373
walk_ty_param_bound(&mut visitor, bound);
@@ -408,12 +405,15 @@ impl<'tcx> Visitor<'tcx> for LifetimeChecker {
408405
self.map.remove(&lifetime.name.name());
409406
}
410407

411-
fn visit_lifetime_def(&mut self, _: &'tcx LifetimeDef) {
408+
fn visit_generic_param(&mut self, param: &'tcx GenericParam) {
412409
// don't actually visit `<'a>` or `<'a: 'b>`
413410
// we've already visited the `'a` declarations and
414411
// don't want to spuriously remove them
415412
// `'b` in `'a: 'b` is useless unless used elsewhere in
416413
// a non-lifetime bound
414+
if param.is_type_param() {
415+
walk_generic_param(self, param)
416+
}
417417
}
418418
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
419419
NestedVisitorMap::None
@@ -422,8 +422,7 @@ impl<'tcx> Visitor<'tcx> for LifetimeChecker {
422422

423423
fn report_extra_lifetimes<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, func: &'tcx FnDecl, generics: &'tcx Generics) {
424424
let hs = generics
425-
.lifetimes
426-
.iter()
425+
.lifetimes()
427426
.map(|lt| (lt.lifetime.name.name(), lt.lifetime.span))
428427
.collect();
429428
let mut checker = LifetimeChecker { map: hs };

clippy_lints/src/methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1849,7 +1849,7 @@ impl SelfKind {
18491849

18501850
fn is_as_ref_or_mut_trait(ty: &hir::Ty, self_ty: &hir::Ty, generics: &hir::Generics, name: &[&str]) -> bool {
18511851
single_segment_ty(ty).map_or(false, |seg| {
1852-
generics.ty_params.iter().any(|param| {
1852+
generics.ty_params().any(|param| {
18531853
param.name == seg.name && param.bounds.iter().any(|bound| {
18541854
if let hir::TyParamBound::TraitTyParamBound(ref ptr, ..) = *bound {
18551855
let path = &ptr.trait_ref.path;

clippy_lints/src/misc_early.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,17 @@ impl LintPass for MiscEarly {
188188

189189
impl EarlyLintPass for MiscEarly {
190190
fn check_generics(&mut self, cx: &EarlyContext, gen: &Generics) {
191-
for ty in &gen.ty_params {
192-
let name = ty.ident.name.as_str();
193-
if constants::BUILTIN_TYPES.contains(&&*name) {
194-
span_lint(
195-
cx,
196-
BUILTIN_TYPE_SHADOW,
197-
ty.span,
198-
&format!("This generic shadows the built-in type `{}`", name),
199-
);
191+
for param in &gen.params {
192+
if let GenericParam::Type(ref ty) = *param {
193+
let name = ty.ident.name.as_str();
194+
if constants::BUILTIN_TYPES.contains(&&*name) {
195+
span_lint(
196+
cx,
197+
BUILTIN_TYPE_SHADOW,
198+
ty.span,
199+
&format!("This generic shadows the built-in type `{}`", name),
200+
);
201+
}
200202
}
201203
}
202204
}

clippy_lints/src/new_without_default.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
103103
// can't be implemented by default
104104
return;
105105
}
106-
if !impl_item.generics.ty_params.is_empty() {
106+
if impl_item.generics.params.iter().any(|gen| gen.is_type_param()) {
107107
// when the result of `new()` depends on a type parameter we should not require
108108
// an
109109
// impl of `Default`

clippy_lints/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ impl<'tcx> Visitor<'tcx> for TypeComplexityVisitor {
957957
TyTraitObject(ref param_bounds, _) => {
958958
let has_lifetime_parameters = param_bounds
959959
.iter()
960-
.any(|bound| !bound.bound_lifetimes.is_empty());
960+
.any(|bound| bound.bound_generic_params.iter().any(|gen| gen.is_lifetime_param()));
961961
if has_lifetime_parameters {
962962
// complex trait bounds like A<'a, 'b>
963963
(50 * self.nest, 1)

0 commit comments

Comments
 (0)