Skip to content

Rustup to rustc 1.24.0-nightly (250b49205 2017-12-21) #2289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 22, 2017
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change Log
All notable changes to this project will be documented in this file.

## 0.0.177
* Rustup to *rustc 1.24.0-nightly (250b49205 2017-12-21)*
* New lint: [`match_as_ref`]

## 0.0.176
* Rustup to *rustc 1.24.0-nightly (0077d128d 2017-12-14)*

Expand Down Expand Up @@ -595,6 +599,7 @@ All notable changes to this project will be documented in this file.
[`many_single_char_names`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#many_single_char_names
[`map_clone`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#map_clone
[`map_entry`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#map_entry
[`match_as_ref`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#match_as_ref
[`match_bool`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#match_bool
[`match_overlapping_arm`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#match_overlapping_arm
[`match_ref_pats`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#match_ref_pats
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.176"
version = "0.0.177"
authors = [
"Manish Goregaokar <[email protected]>",
"Andre Bogus <[email protected]>",
Expand Down Expand Up @@ -37,7 +37,7 @@ path = "src/driver.rs"

[dependencies]
# begin automatic update
clippy_lints = { version = "0.0.176", path = "clippy_lints" }
clippy_lints = { version = "0.0.177", path = "clippy_lints" }
# end automatic update
cargo_metadata = "0.2"
regex = "0.2"
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.176"
version = "0.0.177"
# end automatic update
authors = [
"Manish Goregaokar <[email protected]>",
Expand Down
35 changes: 17 additions & 18 deletions clippy_lints/src/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use reexport::*;
use rustc::lint::*;
use rustc::hir::def::Def;
use rustc::hir::*;
use rustc::hir::intravisit::{walk_fn_decl, walk_generics, walk_ty, walk_ty_param_bound, NestedVisitorMap, Visitor};
use rustc::hir::intravisit::*;
use std::collections::{HashMap, HashSet};
use syntax::codemap::Span;
use utils::{in_external_macro, last_path_segment, span_lint};
Expand Down Expand Up @@ -101,7 +101,7 @@ fn check_fn_inner<'a, 'tcx>(
}

let mut bounds_lts = Vec::new();
for typ in &generics.ty_params {
for typ in generics.ty_params() {
for bound in &typ.bounds {
if let TraitTyParamBound(ref trait_ref, _) = *bound {
let params = &trait_ref
Expand All @@ -122,7 +122,7 @@ fn check_fn_inner<'a, 'tcx>(
}
}
}
if could_use_elision(cx, decl, body, &generics.lifetimes, bounds_lts) {
if could_use_elision(cx, decl, body, &generics.params, bounds_lts) {
span_lint(
cx,
NEEDLESS_LIFETIMES,
Expand All @@ -137,7 +137,7 @@ fn could_use_elision<'a, 'tcx: 'a>(
cx: &LateContext<'a, 'tcx>,
func: &'tcx FnDecl,
body: Option<BodyId>,
named_lts: &'tcx [LifetimeDef],
named_generics: &'tcx [GenericParam],
bounds_lts: Vec<&'tcx Lifetime>,
) -> bool {
// There are two scenarios where elision works:
Expand All @@ -147,7 +147,7 @@ fn could_use_elision<'a, 'tcx: 'a>(
// level of the current item.

// check named LTs
let allowed_lts = allowed_lts_from(named_lts);
let allowed_lts = allowed_lts_from(named_generics);

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

fn allowed_lts_from(named_lts: &[LifetimeDef]) -> HashSet<RefLt> {
fn allowed_lts_from(named_generics: &[GenericParam]) -> HashSet<RefLt> {
let mut allowed_lts = HashSet::new();
for lt in named_lts {
if lt.bounds.is_empty() {
allowed_lts.insert(RefLt::Named(lt.lifetime.name.name()));
for par in named_generics.iter() {
if let GenericParam::Lifetime(ref lt) = *par {
if lt.bounds.is_empty() {
allowed_lts.insert(RefLt::Named(lt.lifetime.name.name()));
}
}
}
allowed_lts.insert(RefLt::Unnamed);
Expand Down Expand Up @@ -332,11 +334,6 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
}
}
}
TyImplTraitUniversal(_, ref param_bounds) => for bound in param_bounds {
if let RegionTyParamBound(_) = *bound {
self.record(&None);
}
},
TyTraitObject(ref bounds, ref lt) => {
if !lt.is_elided() {
self.abort = true;
Expand Down Expand Up @@ -370,7 +367,7 @@ fn has_where_lifetimes<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, where_clause: &
return true;
}
// if the bounds define new lifetimes, they are fine to occur
let allowed_lts = allowed_lts_from(&pred.bound_lifetimes);
let allowed_lts = allowed_lts_from(&pred.bound_generic_params);
// now walk the bounds
for bound in pred.bounds.iter() {
walk_ty_param_bound(&mut visitor, bound);
Expand Down Expand Up @@ -408,12 +405,15 @@ impl<'tcx> Visitor<'tcx> for LifetimeChecker {
self.map.remove(&lifetime.name.name());
}

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

fn report_extra_lifetimes<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, func: &'tcx FnDecl, generics: &'tcx Generics) {
let hs = generics
.lifetimes
.iter()
.lifetimes()
.map(|lt| (lt.lifetime.name.name(), lt.lifetime.span))
.collect();
let mut checker = LifetimeChecker { map: hs };
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1849,7 +1849,7 @@ impl SelfKind {

fn is_as_ref_or_mut_trait(ty: &hir::Ty, self_ty: &hir::Ty, generics: &hir::Generics, name: &[&str]) -> bool {
single_segment_ty(ty).map_or(false, |seg| {
generics.ty_params.iter().any(|param| {
generics.ty_params().any(|param| {
param.name == seg.name && param.bounds.iter().any(|bound| {
if let hir::TyParamBound::TraitTyParamBound(ref ptr, ..) = *bound {
let path = &ptr.trait_ref.path;
Expand Down
20 changes: 11 additions & 9 deletions clippy_lints/src/misc_early.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,17 @@ impl LintPass for MiscEarly {

impl EarlyLintPass for MiscEarly {
fn check_generics(&mut self, cx: &EarlyContext, gen: &Generics) {
for ty in &gen.ty_params {
let name = ty.ident.name.as_str();
if constants::BUILTIN_TYPES.contains(&&*name) {
span_lint(
cx,
BUILTIN_TYPE_SHADOW,
ty.span,
&format!("This generic shadows the built-in type `{}`", name),
);
for param in &gen.params {
if let GenericParam::Type(ref ty) = *param {
let name = ty.ident.name.as_str();
if constants::BUILTIN_TYPES.contains(&&*name) {
span_lint(
cx,
BUILTIN_TYPE_SHADOW,
ty.span,
&format!("This generic shadows the built-in type `{}`", name),
);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/new_without_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
// can't be implemented by default
return;
}
if !impl_item.generics.ty_params.is_empty() {
if impl_item.generics.params.iter().any(|gen| gen.is_type_param()) {
// when the result of `new()` depends on a type parameter we should not require
// an
// impl of `Default`
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ impl<'tcx> Visitor<'tcx> for TypeComplexityVisitor {
TyTraitObject(ref param_bounds, _) => {
let has_lifetime_parameters = param_bounds
.iter()
.any(|bound| !bound.bound_lifetimes.is_empty());
.any(|bound| bound.bound_generic_params.iter().any(|gen| gen.is_lifetime_param()));
if has_lifetime_parameters {
// complex trait bounds like A<'a, 'b>
(50 * self.nest, 1)
Expand Down