Skip to content

Commit b3387b5

Browse files
committed
rustup to 24055d0 2017-01-31
1 parent 22a05ec commit b3387b5

File tree

6 files changed

+27
-32
lines changed

6 files changed

+27
-32
lines changed

clippy_lints/src/attrs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ fn is_relevant_trait(tcx: ty::TyCtxt, item: &TraitItem) -> bool {
181181
}
182182
}
183183

184-
fn is_relevant_block(tcx: ty::TyCtxt, tables: &ty::Tables, block: &Block) -> bool {
184+
fn is_relevant_block(tcx: ty::TyCtxt, tables: &ty::TypeckTables, block: &Block) -> bool {
185185
for stmt in &block.stmts {
186186
match stmt.node {
187187
StmtDecl(_, _) => return true,
@@ -194,7 +194,7 @@ fn is_relevant_block(tcx: ty::TyCtxt, tables: &ty::Tables, block: &Block) -> boo
194194
block.expr.as_ref().map_or(false, |e| is_relevant_expr(tcx, tables, e))
195195
}
196196

197-
fn is_relevant_expr(tcx: ty::TyCtxt, tables: &ty::Tables, expr: &Expr) -> bool {
197+
fn is_relevant_expr(tcx: ty::TyCtxt, tables: &ty::TypeckTables, expr: &Expr) -> bool {
198198
match expr.node {
199199
ExprBlock(ref block) => is_relevant_block(tcx, tables, block),
200200
ExprRet(Some(ref e)) => is_relevant_expr(tcx, tables, e),

clippy_lints/src/escape.rs

+12-15
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,13 @@ declare_lint! {
4040
}
4141

4242
fn is_non_trait_box(ty: ty::Ty) -> bool {
43-
match ty.sty {
44-
ty::TyBox(inner) => !inner.is_trait(),
45-
_ => false,
46-
}
43+
ty.is_box() && !ty.boxed_ty().is_trait()
4744
}
4845

4946
struct EscapeDelegate<'a, 'tcx: 'a> {
5047
set: NodeSet,
5148
tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
52-
tables: &'a ty::Tables<'tcx>,
49+
tables: &'a ty::TypeckTables<'tcx>,
5350
target: TargetDataLayout,
5451
too_large_for_stack: u64,
5552
}
@@ -204,16 +201,16 @@ impl<'a, 'tcx: 'a> EscapeDelegate<'a, 'tcx> {
204201
fn is_large_box(&self, ty: ty::Ty<'tcx>) -> bool {
205202
// Large types need to be boxed to avoid stack
206203
// overflows.
207-
match ty.sty {
208-
ty::TyBox(inner) => {
209-
self.tcx.infer_ctxt((), Reveal::All).enter(|infcx| if let Ok(layout) = inner.layout(&infcx) {
210-
let size = layout.size(&self.target);
211-
size.bytes() > self.too_large_for_stack
212-
} else {
213-
false
214-
})
215-
},
216-
_ => false,
204+
if ty.is_box() {
205+
let inner = ty.boxed_ty();
206+
self.tcx.infer_ctxt((), Reveal::All).enter(|infcx| if let Ok(layout) = inner.layout(&infcx) {
207+
let size = layout.size(&self.target);
208+
size.bytes() > self.too_large_for_stack
209+
} else {
210+
false
211+
})
212+
} else {
213+
false
217214
}
218215
}
219216
}

clippy_lints/src/lifetimes.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ impl<'v, 't> RefVisitor<'v, 't> {
230230
if let Some(ref lt) = *lifetime {
231231
if &*lt.name.as_str() == "'static" {
232232
self.lts.push(RefLt::Static);
233+
} else if lt.is_elided() {
234+
// TODO: investigate
235+
self.lts.push(RefLt::Unnamed);
233236
} else {
234237
self.lts.push(RefLt::Named(lt.name));
235238
}
@@ -275,9 +278,6 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
275278

276279
fn visit_ty(&mut self, ty: &'tcx Ty) {
277280
match ty.node {
278-
TyRptr(None, _) => {
279-
self.record(&None);
280-
},
281281
TyPath(ref path) => {
282282
self.collect_anonymous_lifetimes(path, ty);
283283
},

clippy_lints/src/methods.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -951,8 +951,7 @@ fn derefs_to_slice(cx: &LateContext, expr: &hir::Expr, ty: ty::Ty) -> Option<sug
951951
ty::TySlice(_) => true,
952952
ty::TyAdt(..) => match_type(cx, ty, &paths::VEC),
953953
ty::TyArray(_, size) => size < 32,
954-
ty::TyRef(_, ty::TypeAndMut { ty: inner, .. }) |
955-
ty::TyBox(inner) => may_slice(cx, inner),
954+
ty::TyRef(_, ty::TypeAndMut { ty: inner, .. }) => may_slice(cx, inner),
956955
_ => false,
957956
}
958957
}
@@ -966,8 +965,7 @@ fn derefs_to_slice(cx: &LateContext, expr: &hir::Expr, ty: ty::Ty) -> Option<sug
966965
} else {
967966
match ty.sty {
968967
ty::TySlice(_) => sugg::Sugg::hir_opt(cx, expr),
969-
ty::TyRef(_, ty::TypeAndMut { ty: inner, .. }) |
970-
ty::TyBox(inner) => {
968+
ty::TyRef(_, ty::TypeAndMut { ty: inner, .. }) => {
971969
if may_slice(cx, inner) {
972970
sugg::Sugg::hir_opt(cx, expr)
973971
} else {

clippy_lints/src/types.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -702,13 +702,10 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for TypeComplexityVisitor<'a, 'tcx> {
702702
// function types bring a lot of overhead
703703
TyBareFn(..) => (50 * self.nest, 1),
704704

705-
TyTraitObject(ref bounds) => {
706-
let has_lifetimes = bounds.iter()
707-
.any(|bound| match *bound {
708-
TraitTyParamBound(ref poly_trait, ..) => !poly_trait.bound_lifetimes.is_empty(),
709-
RegionTyParamBound(..) => true,
710-
});
711-
if has_lifetimes {
705+
TyTraitObject(ref param_bounds, _) => {
706+
let has_lifetime_parameters = param_bounds.iter()
707+
.any(|bound| !bound.bound_lifetimes.is_empty());
708+
if has_lifetime_parameters {
712709
// complex trait bounds like A<'a, 'b>
713710
(50 * self.nest, 1)
714711
} else {

clippy_lints/src/utils/internal_lints.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass {
142142

143143

144144
fn is_lint_ref_type(ty: &Ty) -> bool {
145-
if let TyRptr(_, MutTy { ty: ref inner, mutbl: MutImmutable }) = ty.node {
145+
if let TyRptr(ref lt, MutTy { ty: ref inner, mutbl: MutImmutable }) = ty.node {
146+
if lt.is_elided() {
147+
return false;
148+
}
146149
if let TyPath(ref path) = inner.node {
147150
return match_path(path, &paths::LINT);
148151
}

0 commit comments

Comments
 (0)