Skip to content

Commit

Permalink
Rustup to nightly from 2017-01-31
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrmaxmeier committed Feb 3, 2017
1 parent 22a05ec commit c59abc3
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 30 deletions.
4 changes: 2 additions & 2 deletions clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
Expand Down
27 changes: 12 additions & 15 deletions clippy_lints/src/escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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
}
}
}
5 changes: 4 additions & 1 deletion clippy_lints/src/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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) => {
Expand Down
6 changes: 2 additions & 4 deletions clippy_lints/src/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -951,8 +951,7 @@ fn derefs_to_slice(cx: &LateContext, expr: &hir::Expr, ty: ty::Ty) -> Option<sug
ty::TySlice(_) => 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,
}
}
Expand All @@ -966,8 +965,7 @@ fn derefs_to_slice(cx: &LateContext, expr: &hir::Expr, ty: ty::Ty) -> Option<sug
} else {
match ty.sty {
ty::TySlice(_) => 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 {
Expand Down
11 changes: 4 additions & 7 deletions clippy_lints/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion clippy_lints/src/utils/internal_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit c59abc3

Please sign in to comment.