Skip to content

Commit 49bf976

Browse files
authored
Merge pull request #1505 from Mrmaxmeier/rustup-2017-01-31
Rustup to rustc 1.16.0-nightly (24055d0 2017-01-31)
2 parents b1be0d6 + 384eb82 commit 49bf976

35 files changed

+112
-107
lines changed

clippy_lints/src/assign_ops.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
143143
return; // useless if the trait doesn't exist
144144
};
145145
// check that we are not inside an `impl AssignOp` of this exact operation
146-
let parent_fn = cx.tcx.map.get_parent(e.id);
147-
let parent_impl = cx.tcx.map.get_parent(parent_fn);
146+
let parent_fn = cx.tcx.hir.get_parent(e.id);
147+
let parent_impl = cx.tcx.hir.get_parent(parent_fn);
148148
// the crate node is the only one that is not in the map
149149
if_let_chain!{[
150150
parent_impl != ast::CRATE_NODE_ID,
151-
let hir::map::Node::NodeItem(item) = cx.tcx.map.get(parent_impl),
151+
let hir::map::Node::NodeItem(item) = cx.tcx.hir.get(parent_impl),
152152
let hir::Item_::ItemImpl(_, _, _, Some(ref trait_ref), _, _) = item.node,
153153
trait_ref.path.def.def_id() == trait_id
154154
], { return; }}

clippy_lints/src/attrs.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
158158

159159
fn is_relevant_item(tcx: ty::TyCtxt, item: &Item) -> bool {
160160
if let ItemFn(_, _, _, _, _, eid) = item.node {
161-
is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.map.body(eid).value)
161+
is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.hir.body(eid).value)
162162
} else {
163163
false
164164
}
165165
}
166166

167167
fn is_relevant_impl(tcx: ty::TyCtxt, item: &ImplItem) -> bool {
168168
match item.node {
169-
ImplItemKind::Method(_, eid) => is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.map.body(eid).value),
169+
ImplItemKind::Method(_, eid) => is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.hir.body(eid).value),
170170
_ => false,
171171
}
172172
}
@@ -175,13 +175,13 @@ fn is_relevant_trait(tcx: ty::TyCtxt, item: &TraitItem) -> bool {
175175
match item.node {
176176
TraitItemKind::Method(_, TraitMethod::Required(_)) => true,
177177
TraitItemKind::Method(_, TraitMethod::Provided(eid)) => {
178-
is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.map.body(eid).value)
178+
is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.hir.body(eid).value)
179179
},
180180
_ => false,
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/block_in_if_condition.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct ExVisitor<'a, 'tcx: 'a> {
5757
impl<'a, 'tcx: 'a> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
5858
fn visit_expr(&mut self, expr: &'tcx Expr) {
5959
if let ExprClosure(_, _, eid, _) = expr.node {
60-
let body = self.cx.tcx.map.body(eid);
60+
let body = self.cx.tcx.hir.body(eid);
6161
let ex = &body.value;
6262
if matches!(ex.node, ExprBlock(_)) {
6363
self.found_block = Some(ex);
@@ -67,7 +67,7 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
6767
walk_expr(self, expr);
6868
}
6969
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
70-
NestedVisitorMap::All(&self.cx.tcx.map)
70+
NestedVisitorMap::All(&self.cx.tcx.hir)
7171
}
7272
}
7373

clippy_lints/src/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
263263
ExprRepeat(ref value, number_id) => {
264264
if let Some(lcx) = self.lcx {
265265
self.binop_apply(value,
266-
&lcx.tcx.map.body(number_id).value,
266+
&lcx.tcx.hir.body(number_id).value,
267267
|v, n| Some(Constant::Repeat(Box::new(v), n.as_u64() as usize)))
268268
} else {
269269
None

clippy_lints/src/cyclomatic_complexity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CyclomaticComplexity {
9999
span: Span,
100100
node_id: NodeId
101101
) {
102-
let def_id = cx.tcx.map.local_def_id(node_id);
102+
let def_id = cx.tcx.hir.local_def_id(node_id);
103103
if !cx.tcx.has_attr(def_id, "test") {
104104
self.check(cx, &body.value, span);
105105
}

clippy_lints/src/derive.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl LintPass for Derive {
7373
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Derive {
7474
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
7575
if let ItemImpl(_, _, _, Some(ref trait_ref), _, _) = item.node {
76-
let ty = cx.tcx.item_type(cx.tcx.map.local_def_id(item.id));
76+
let ty = cx.tcx.item_type(cx.tcx.hir.local_def_id(item.id));
7777
let is_automatically_derived = is_automatically_derived(&*item.attrs);
7878

7979
check_hash_peq(cx, item.span, trait_ref, ty, is_automatically_derived);
@@ -122,9 +122,9 @@ fn check_hash_peq<'a, 'tcx>(
122122
cx, DERIVE_HASH_XOR_EQ, span,
123123
mess,
124124
|db| {
125-
if let Some(node_id) = cx.tcx.map.as_local_node_id(impl_id) {
125+
if let Some(node_id) = cx.tcx.hir.as_local_node_id(impl_id) {
126126
db.span_note(
127-
cx.tcx.map.span(node_id),
127+
cx.tcx.hir.span(node_id),
128128
"`PartialEq` implemented here"
129129
);
130130
}

clippy_lints/src/entry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,6 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> {
148148
}
149149
}
150150
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
151-
NestedVisitorMap::All(&self.cx.tcx.map)
151+
NestedVisitorMap::All(&self.cx.tcx.hir)
152152
}
153153
}

clippy_lints/src/enum_clike.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
4545
if let Some(body_id) = variant.disr_expr {
4646
use rustc_const_eval::*;
4747
let constcx = ConstContext::new(cx.tcx, body_id);
48-
let bad = match constcx.eval(&cx.tcx.map.body(body_id).value, EvalHint::ExprTypeChecked) {
48+
let bad = match constcx.eval(&cx.tcx.hir.body(body_id).value, EvalHint::ExprTypeChecked) {
4949
Ok(ConstVal::Integral(Usize(Us64(i)))) => i as u32 as u64 != i,
5050
Ok(ConstVal::Integral(Isize(Is64(i)))) => i as i32 as i64 != i,
5151
_ => false,

clippy_lints/src/escape.rs

Lines changed: 15 additions & 18 deletions
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
}
@@ -89,7 +86,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
8986
for node in v.set {
9087
span_lint(cx,
9188
BOXED_LOCAL,
92-
cx.tcx.map.span(node),
89+
cx.tcx.hir.span(node),
9390
"local variable doesn't need to be boxed here");
9491
}
9592
}
@@ -108,7 +105,7 @@ impl<'a, 'tcx: 'a> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
108105
}
109106
fn matched_pat(&mut self, _: &Pat, _: cmt<'tcx>, _: MatchMode) {}
110107
fn consume_pat(&mut self, consume_pat: &Pat, cmt: cmt<'tcx>, _: ConsumeMode) {
111-
let map = &self.tcx.map;
108+
let map = &self.tcx.hir;
112109
if map.is_argument(consume_pat.id) {
113110
// Skip closure arguments
114111
if let Some(NodeExpr(..)) = map.find(map.get_parent_node(consume_pat.id)) {
@@ -180,7 +177,7 @@ impl<'a, 'tcx: 'a> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
180177
self.tables
181178
.adjustments
182179
.get(&self.tcx
183-
.map
180+
.hir
184181
.get_parent_node(borrow_id))
185182
.map(|a| &a.kind) {
186183
if autoderefs <= 1 {
@@ -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/eta_reduction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EtaPass {
4949

5050
fn check_closure(cx: &LateContext, expr: &Expr) {
5151
if let ExprClosure(_, ref decl, eid, _) = expr.node {
52-
let body = cx.tcx.map.body(eid);
52+
let body = cx.tcx.hir.body(eid);
5353
let ex = &body.value;
5454
if let ExprCall(ref caller, ref args) = ex.node {
5555
if args.len() != decl.inputs.len() {

clippy_lints/src/eval_order_dependence.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
156156
// don't continue over blocks, LateLintPass already does that
157157
}
158158
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
159-
NestedVisitorMap::All(&self.cx.tcx.map)
159+
NestedVisitorMap::All(&self.cx.tcx.hir)
160160
}
161161
}
162162

@@ -176,7 +176,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
176176
///
177177
/// When such a read is found, the lint is triggered.
178178
fn check_for_unsequenced_reads(vis: &mut ReadVisitor) {
179-
let map = &vis.cx.tcx.map;
179+
let map = &vis.cx.tcx.hir;
180180
let mut cur_id = vis.write_expr.id;
181181
loop {
182182
let parent_id = map.get_parent_node(cur_id);
@@ -342,7 +342,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReadVisitor<'a, 'tcx> {
342342
walk_expr(self, expr);
343343
}
344344
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
345-
NestedVisitorMap::All(&self.cx.tcx.map)
345+
NestedVisitorMap::All(&self.cx.tcx.hir)
346346
}
347347
}
348348

clippy_lints/src/format.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ pub fn get_argument_fmtstr_parts<'a, 'b>(cx: &LateContext<'a, 'b>, expr: &'a Exp
7878
block.stmts.len() == 1,
7979
let StmtDecl(ref decl, _) = block.stmts[0].node,
8080
let DeclItem(ref decl) = decl.node,
81-
let Some(NodeItem(decl)) = cx.tcx.map.find(decl.id),
81+
let Some(NodeItem(decl)) = cx.tcx.hir.find(decl.id),
8282
&*decl.name.as_str() == "__STATIC_FMTSTR",
8383
let ItemStatic(_, _, ref expr) = decl.node,
84-
let ExprAddrOf(_, ref expr) = cx.tcx.map.body(*expr).value.node, // &["…", "…", …]
84+
let ExprAddrOf(_, ref expr) = cx.tcx.hir.body(*expr).value.node, // &["…", "…", …]
8585
let ExprArray(ref exprs) = expr.node,
8686
], {
8787
let mut result = Vec::new();

clippy_lints/src/functions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
8080
) {
8181
use rustc::hir::map::Node::*;
8282

83-
let is_impl = if let Some(NodeItem(item)) = cx.tcx.map.find(cx.tcx.map.get_parent_node(nodeid)) {
83+
let is_impl = if let Some(NodeItem(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(nodeid)) {
8484
matches!(item.node, hir::ItemImpl(_, _, _, Some(_), _, _) | hir::ItemDefaultImpl(..))
8585
} else {
8686
false
@@ -113,7 +113,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
113113
}
114114

115115
if let hir::TraitMethod::Provided(eid) = *eid {
116-
let body = cx.tcx.map.body(eid);
116+
let body = cx.tcx.hir.body(eid);
117117
self.check_raw_ptr(cx, sig.unsafety, &sig.decl, body, item.id);
118118
}
119119
}
@@ -200,7 +200,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> {
200200
hir::intravisit::walk_expr(self, expr);
201201
}
202202
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> {
203-
intravisit::NestedVisitorMap::All(&self.cx.tcx.map)
203+
intravisit::NestedVisitorMap::All(&self.cx.tcx.hir)
204204
}
205205
}
206206

clippy_lints/src/large_enum_variant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl LintPass for LargeEnumVariant {
4646

4747
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeEnumVariant {
4848
fn check_item(&mut self, cx: &LateContext, item: &Item) {
49-
let did = cx.tcx.map.local_def_id(item.id);
49+
let did = cx.tcx.hir.local_def_id(item.id);
5050
if let ItemEnum(ref def, _) = item.node {
5151
let ty = cx.tcx.item_type(did);
5252
let adt = ty.ty_adt_def().expect("already checked whether this is an enum");

clippy_lints/src/len_zero.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ fn check_trait_items(cx: &LateContext, item: &Item, trait_items: &[TraitItemRef]
9393
if let AssociatedItemKind::Method { has_self } = item.kind {
9494
has_self &&
9595
{
96-
let did = cx.tcx.map.local_def_id(item.id.node_id);
96+
let did = cx.tcx.hir.local_def_id(item.id.node_id);
9797
let impl_ty = cx.tcx.item_type(did);
9898
impl_ty.fn_args().skip_binder().len() == 1
9999
}
@@ -120,7 +120,7 @@ fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItemRef]) {
120120
if let AssociatedItemKind::Method { has_self } = item.kind {
121121
has_self &&
122122
{
123-
let did = cx.tcx.map.local_def_id(item.id.node_id);
123+
let did = cx.tcx.hir.local_def_id(item.id.node_id);
124124
let impl_ty = cx.tcx.item_type(did);
125125
impl_ty.fn_args().skip_binder().len() == 1
126126
}
@@ -141,7 +141,7 @@ fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItemRef]) {
141141

142142
if let Some(i) = impl_items.iter().find(|i| is_named_self(cx, i, "len")) {
143143
if cx.access_levels.is_exported(i.id.node_id) {
144-
let def_id = cx.tcx.map.local_def_id(item.id);
144+
let def_id = cx.tcx.hir.local_def_id(item.id);
145145
let ty = cx.tcx.item_type(def_id);
146146

147147
span_lint(cx,

clippy_lints/src/let_if_seq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for UsedVisitor<'a, 'tcx> {
145145
hir::intravisit::walk_expr(self, expr);
146146
}
147147
fn nested_visit_map<'this>(&'this mut self) -> hir::intravisit::NestedVisitorMap<'this, 'tcx> {
148-
hir::intravisit::NestedVisitorMap::All(&self.cx.tcx.map)
148+
hir::intravisit::NestedVisitorMap::All(&self.cx.tcx.hir)
149149
}
150150
}
151151

clippy_lints/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#![feature(rustc_private)]
99
#![feature(slice_patterns)]
1010
#![feature(stmt_expr_attributes)]
11-
#![feature(repeat_str)]
1211
#![feature(conservative_impl_trait)]
1312
#![feature(collections_bound)]
1413

clippy_lints/src/lifetimes.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ 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+
self.lts.push(RefLt::Unnamed);
233235
} else {
234236
self.lts.push(RefLt::Named(lt.name));
235237
}
@@ -275,7 +277,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
275277

276278
fn visit_ty(&mut self, ty: &'tcx Ty) {
277279
match ty.node {
278-
TyRptr(None, _) => {
280+
TyRptr(ref lt, _) if lt.is_elided() => {
279281
self.record(&None);
280282
},
281283
TyPath(ref path) => {
@@ -288,6 +290,15 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
288290
}
289291
}
290292
},
293+
TyTraitObject(ref bounds, ref lt) => {
294+
if !lt.is_elided() {
295+
self.record(&Some(*lt));
296+
}
297+
for bound in bounds {
298+
self.visit_poly_trait_ref(bound, TraitBoundModifier::None);
299+
}
300+
return;
301+
},
291302
_ => (),
292303
}
293304
walk_ty(self, ty);

0 commit comments

Comments
 (0)