From c59abc3d9966b2c43113285e2d64afee2b839878 Mon Sep 17 00:00:00 2001 From: Mrmaxmeier Date: Fri, 3 Feb 2017 11:52:13 +0100 Subject: [PATCH] Rustup to nightly from 2017-01-31 --- clippy_lints/src/attrs.rs | 4 ++-- clippy_lints/src/escape.rs | 27 +++++++++++------------- clippy_lints/src/lifetimes.rs | 5 ++++- clippy_lints/src/methods.rs | 6 ++---- clippy_lints/src/types.rs | 11 ++++------ clippy_lints/src/utils/internal_lints.rs | 5 ++++- 6 files changed, 28 insertions(+), 30 deletions(-) diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index bf6f165cdd80..30115c60572a 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -181,7 +181,7 @@ fn is_relevant_trait(tcx: ty::TyCtxt, item: &TraitItem) -> bool { } } -fn is_relevant_block(tcx: ty::TyCtxt, tables: &ty::Tables, block: &Block) -> bool { +fn is_relevant_block(tcx: ty::TyCtxt, tables: &ty::TypeckTables, block: &Block) -> bool { for stmt in &block.stmts { match stmt.node { StmtDecl(_, _) => return true, @@ -194,7 +194,7 @@ fn is_relevant_block(tcx: ty::TyCtxt, tables: &ty::Tables, block: &Block) -> boo block.expr.as_ref().map_or(false, |e| is_relevant_expr(tcx, tables, e)) } -fn is_relevant_expr(tcx: ty::TyCtxt, tables: &ty::Tables, expr: &Expr) -> bool { +fn is_relevant_expr(tcx: ty::TyCtxt, tables: &ty::TypeckTables, expr: &Expr) -> bool { match expr.node { ExprBlock(ref block) => is_relevant_block(tcx, tables, block), ExprRet(Some(ref e)) => is_relevant_expr(tcx, tables, e), diff --git a/clippy_lints/src/escape.rs b/clippy_lints/src/escape.rs index 2a53cab8cd2e..0db45efeb386 100644 --- a/clippy_lints/src/escape.rs +++ b/clippy_lints/src/escape.rs @@ -40,16 +40,13 @@ declare_lint! { } fn is_non_trait_box(ty: ty::Ty) -> bool { - match ty.sty { - ty::TyBox(inner) => !inner.is_trait(), - _ => false, - } + ty.is_box() && !ty.boxed_ty().is_trait() } struct EscapeDelegate<'a, 'tcx: 'a> { set: NodeSet, tcx: ty::TyCtxt<'a, 'tcx, 'tcx>, - tables: &'a ty::Tables<'tcx>, + tables: &'a ty::TypeckTables<'tcx>, target: TargetDataLayout, too_large_for_stack: u64, } @@ -204,16 +201,16 @@ impl<'a, 'tcx: 'a> EscapeDelegate<'a, 'tcx> { fn is_large_box(&self, ty: ty::Ty<'tcx>) -> bool { // Large types need to be boxed to avoid stack // overflows. - match ty.sty { - ty::TyBox(inner) => { - self.tcx.infer_ctxt((), Reveal::All).enter(|infcx| if let Ok(layout) = inner.layout(&infcx) { - let size = layout.size(&self.target); - size.bytes() > self.too_large_for_stack - } else { - false - }) - }, - _ => false, + if ty.is_box() { + let inner = ty.boxed_ty(); + self.tcx.infer_ctxt((), Reveal::All).enter(|infcx| if let Ok(layout) = inner.layout(&infcx) { + let size = layout.size(&self.target); + size.bytes() > self.too_large_for_stack + } else { + false + }) + } else { + false } } } diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index 720cf29247c2..90fcc79dec45 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -230,6 +230,9 @@ impl<'v, 't> RefVisitor<'v, 't> { if let Some(ref lt) = *lifetime { if &*lt.name.as_str() == "'static" { self.lts.push(RefLt::Static); + } else if lt.is_elided() { + // TODO: investigate + self.lts.push(RefLt::Unnamed); } else { self.lts.push(RefLt::Named(lt.name)); } @@ -275,7 +278,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> { fn visit_ty(&mut self, ty: &'tcx Ty) { match ty.node { - TyRptr(None, _) => { + TyRptr(ref lt, _) if lt.is_elided() => { self.record(&None); }, TyPath(ref path) => { diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index 3ad649b93da0..c3198d1dd782 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -951,8 +951,7 @@ fn derefs_to_slice(cx: &LateContext, expr: &hir::Expr, ty: ty::Ty) -> Option true, ty::TyAdt(..) => match_type(cx, ty, &paths::VEC), ty::TyArray(_, size) => size < 32, - ty::TyRef(_, ty::TypeAndMut { ty: inner, .. }) | - ty::TyBox(inner) => may_slice(cx, inner), + ty::TyRef(_, ty::TypeAndMut { ty: inner, .. }) => may_slice(cx, inner), _ => false, } } @@ -966,8 +965,7 @@ fn derefs_to_slice(cx: &LateContext, expr: &hir::Expr, ty: ty::Ty) -> Option sugg::Sugg::hir_opt(cx, expr), - ty::TyRef(_, ty::TypeAndMut { ty: inner, .. }) | - ty::TyBox(inner) => { + ty::TyRef(_, ty::TypeAndMut { ty: inner, .. }) => { if may_slice(cx, inner) { sugg::Sugg::hir_opt(cx, expr) } else { diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index 5656af664499..ccdcb94d212c 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -702,13 +702,10 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for TypeComplexityVisitor<'a, 'tcx> { // function types bring a lot of overhead TyBareFn(..) => (50 * self.nest, 1), - TyTraitObject(ref bounds) => { - let has_lifetimes = bounds.iter() - .any(|bound| match *bound { - TraitTyParamBound(ref poly_trait, ..) => !poly_trait.bound_lifetimes.is_empty(), - RegionTyParamBound(..) => true, - }); - if has_lifetimes { + TyTraitObject(ref param_bounds, _) => { + let has_lifetime_parameters = param_bounds.iter() + .any(|bound| !bound.bound_lifetimes.is_empty()); + if has_lifetime_parameters { // complex trait bounds like A<'a, 'b> (50 * self.nest, 1) } else { diff --git a/clippy_lints/src/utils/internal_lints.rs b/clippy_lints/src/utils/internal_lints.rs index c41fe2fb49fd..41e9d7773639 100644 --- a/clippy_lints/src/utils/internal_lints.rs +++ b/clippy_lints/src/utils/internal_lints.rs @@ -142,7 +142,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass { fn is_lint_ref_type(ty: &Ty) -> bool { - if let TyRptr(_, MutTy { ty: ref inner, mutbl: MutImmutable }) = ty.node { + if let TyRptr(ref lt, MutTy { ty: ref inner, mutbl: MutImmutable }) = ty.node { + if lt.is_elided() { + return false; + } if let TyPath(ref path) = inner.node { return match_path(path, &paths::LINT); }