Skip to content

Commit 5a6e48f

Browse files
authored
Merge pull request #1808 from messense/feature/try-fix-nightly
Try to fix compilation error on rustc 1.19.0-nightly 4ed2eda
2 parents 892cc28 + 5b4e7b5 commit 5a6e48f

18 files changed

+152
-148
lines changed

CHANGELOG.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4-
## 0.0.136 - 2017-05-26
4+
## 0.0.137 — 2017-06-05
5+
* Update to *rustc 1.19.0-nightly (6684d176c 2017-06-03)*
6+
7+
## 0.0.136 — 2017—05—26
58
* Update to *rustc 1.19.0-nightly (557967766 2017-05-26)*
69

7-
## 0.0.135 - 2017-05-24
10+
## 0.0.135 2017—05—24
811
* Update to *rustc 1.19.0-nightly (5b13bff52 2017-05-23)*
912

10-
## 0.0.134 - 2017-05-19
13+
## 0.0.134 2017—05—19
1114
* Update to *rustc 1.19.0-nightly (0ed1ec9f9 2017-05-18)*
1215

13-
## 0.0.133 - 2017-05-14
16+
## 0.0.133 2017—05—14
1417
* Update to *rustc 1.19.0-nightly (826d8f385 2017-05-13)*
1518

16-
## 0.0.132 - 2017-05-05
19+
## 0.0.132 2017—05—05
1720
* Fix various bugs and some ices
1821

19-
## 0.0.131 - 2017-05-04
22+
## 0.0.131 2017—05—04
2023
* Update to *rustc 1.19.0-nightly (2d4ed8e0c 2017-05-03)*
2124

22-
## 0.0.130 - 2017-05-03
25+
## 0.0.130 2017—05—03
2326
* Update to *rustc 1.19.0-nightly (6a5fc9eec 2017-05-02)*
2427

2528
## 0.0.129 — 2017-05-01

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.0.136"
3+
version = "0.0.137"
44
authors = [
55
"Manish Goregaokar <[email protected]>",
66
"Andre Bogus <[email protected]>",
@@ -31,7 +31,7 @@ test = false
3131

3232
[dependencies]
3333
# begin automatic update
34-
clippy_lints = { version = "0.0.136", path = "clippy_lints" }
34+
clippy_lints = { version = "0.0.137", path = "clippy_lints" }
3535
# end automatic update
3636
cargo_metadata = "0.2"
3737

clippy_lints/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "clippy_lints"
33
# begin automatic update
4-
version = "0.0.136"
4+
version = "0.0.137"
55
# end automatic update
66
authors = [
77
"Manish Goregaokar <[email protected]>",

clippy_lints/src/consts.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
286286
match def {
287287
Def::Const(def_id) |
288288
Def::AssociatedConst(def_id) => {
289-
let substs = self.tables
290-
.node_id_item_substs(id)
291-
.unwrap_or_else(|| self.tcx.intern_substs(&[]));
289+
let substs = self.tables.node_substs(id);
292290
let substs = if self.substs.is_empty() {
293291
substs
294292
} else {

clippy_lints/src/escape.rs

Lines changed: 34 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ use rustc::lint::*;
55
use rustc::middle::expr_use_visitor::*;
66
use rustc::middle::mem_categorization::{cmt, Categorization};
77
use rustc::ty;
8-
use rustc::ty::layout::TargetDataLayout;
9-
use rustc::traits::Reveal;
108
use rustc::util::nodemap::NodeSet;
119
use syntax::ast::NodeId;
1210
use syntax::codemap::Span;
@@ -46,8 +44,7 @@ fn is_non_trait_box(ty: ty::Ty) -> bool {
4644
struct EscapeDelegate<'a, 'tcx: 'a> {
4745
set: NodeSet,
4846
tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
49-
tables: &'a ty::TypeckTables<'tcx>,
50-
target: TargetDataLayout,
47+
param_env: ty::ParamEnv<'tcx>,
5148
too_large_for_stack: u64,
5249
}
5350

@@ -67,23 +64,20 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
6764
_: Span,
6865
node_id: NodeId
6966
) {
70-
// we store the infcx because it is expensive to recreate
71-
// the context each time.
67+
let fn_def_id = cx.tcx.hir.local_def_id(node_id);
68+
let param_env = cx.tcx.param_env(fn_def_id).reveal_all();
7269
let mut v = EscapeDelegate {
7370
set: NodeSet(),
7471
tcx: cx.tcx,
75-
tables: cx.tables,
76-
target: TargetDataLayout::parse(cx.sess()),
72+
param_env: param_env,
7773
too_large_for_stack: self.too_large_for_stack,
7874
};
7975

80-
let infcx = cx.tcx.borrowck_fake_infer_ctxt(body.id());
81-
let fn_def_id = cx.tcx.hir.local_def_id(node_id);
82-
let region_maps = &cx.tcx.region_maps(fn_def_id);
83-
{
84-
let mut vis = ExprUseVisitor::new(&mut v, region_maps, &infcx);
76+
cx.tcx.infer_ctxt(body.id()).enter(|infcx| {
77+
let region_maps = &cx.tcx.region_maps(fn_def_id);
78+
let mut vis = ExprUseVisitor::new(&mut v, region_maps, &infcx, param_env);
8579
vis.consume_body(body);
86-
}
80+
});
8781

8882
for node in v.set {
8983
span_lint(cx,
@@ -94,14 +88,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
9488
}
9589
}
9690

97-
impl<'a, 'tcx: 'a> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
91+
impl<'a, 'gcx: 'tcx, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'gcx> {
9892
fn consume(&mut self, _: NodeId, _: Span, cmt: cmt<'tcx>, mode: ConsumeMode) {
9993
if let Categorization::Local(lid) = cmt.cat {
100-
if self.set.contains(&lid) {
101-
if let Move(DirectRefMove) = mode {
102-
// moved out or in. clearly can't be localized
103-
self.set.remove(&lid);
104-
}
94+
if let Move(DirectRefMove) = mode {
95+
// moved out or in. clearly can't be localized
96+
self.set.remove(&lid);
10597
}
10698
}
10799
}
@@ -149,49 +141,30 @@ impl<'a, 'tcx: 'a> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
149141
}
150142
fn borrow(
151143
&mut self,
152-
borrow_id: NodeId,
144+
_: NodeId,
153145
_: Span,
154146
cmt: cmt<'tcx>,
155147
_: ty::Region,
156148
_: ty::BorrowKind,
157149
loan_cause: LoanCause
158150
) {
159-
use rustc::ty::adjustment::Adjust;
160-
161151
if let Categorization::Local(lid) = cmt.cat {
162-
if self.set.contains(&lid) {
163-
if let Some(&Adjust::DerefRef { autoderefs, .. }) =
164-
self.tables
165-
.adjustments
166-
.get(&borrow_id)
167-
.map(|a| &a.kind) {
168-
if LoanCause::AutoRef == loan_cause {
169-
// x.foo()
170-
if autoderefs == 0 {
171-
self.set.remove(&lid); // Used without autodereffing (i.e. x.clone())
172-
}
173-
} else {
174-
span_bug!(cmt.span, "Unknown adjusted AutoRef");
175-
}
176-
} else if LoanCause::AddrOf == loan_cause {
177-
// &x
178-
if let Some(&Adjust::DerefRef { autoderefs, .. }) =
179-
self.tables
180-
.adjustments
181-
.get(&self.tcx
182-
.hir
183-
.get_parent_node(borrow_id))
184-
.map(|a| &a.kind) {
185-
if autoderefs <= 1 {
186-
// foo(&x) where no extra autoreffing is happening
187-
self.set.remove(&lid);
188-
}
189-
}
152+
match loan_cause {
153+
// x.foo()
154+
// Used without autodereffing (i.e. x.clone())
155+
LoanCause::AutoRef |
190156

191-
} else if LoanCause::MatchDiscriminant == loan_cause {
192-
self.set.remove(&lid); // `match x` can move
157+
// &x
158+
// foo(&x) where no extra autoreffing is happening
159+
LoanCause::AddrOf |
160+
161+
// `match x` can move
162+
LoanCause::MatchDiscriminant => {
163+
self.set.remove(&lid);
193164
}
165+
194166
// do nothing for matches, etc. These can't escape
167+
_ => {}
195168
}
196169
}
197170
}
@@ -200,19 +173,17 @@ impl<'a, 'tcx: 'a> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
200173
}
201174

202175
impl<'a, 'tcx: 'a> EscapeDelegate<'a, 'tcx> {
203-
fn is_large_box(&self, ty: ty::Ty<'tcx>) -> bool {
176+
fn is_large_box(&self, ty: ty::Ty) -> bool {
204177
// Large types need to be boxed to avoid stack
205178
// overflows.
206179
if ty.is_box() {
207-
let inner = ty.boxed_ty();
208-
self.tcx.infer_ctxt((), Reveal::All).enter(|infcx| if let Ok(layout) = inner.layout(&infcx) {
209-
let size = layout.size(&self.target);
210-
size.bytes() > self.too_large_for_stack
211-
} else {
212-
false
213-
})
214-
} else {
215-
false
180+
if let Some(inner) = self.tcx.lift(&ty.boxed_ty()) {
181+
if let Ok(layout) = inner.layout(self.tcx, self.param_env) {
182+
return layout.size(self.tcx).bytes() > self.too_large_for_stack;
183+
}
184+
}
216185
}
186+
187+
false
217188
}
218189
}

clippy_lints/src/eval_order_dependence.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,8 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
137137
}
138138
},
139139
ExprMethodCall(..) => {
140-
let method_call = ty::MethodCall::expr(e.id);
141140
let borrowed_table = self.cx.tables;
142-
let method_type = borrowed_table.method_map.get(&method_call).expect("This should never happen.");
143-
let result_ty = method_type.ty.fn_ret();
144-
if let ty::TyNever = self.cx.tcx.erase_late_bound_regions(&result_ty).sty {
141+
if borrowed_table.expr_ty(e).is_never() {
145142
self.report_diverging_sub_expr(e);
146143
}
147144
},

clippy_lints/src/functions.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use rustc::hir::intravisit;
22
use rustc::hir;
3-
use rustc::ty;
43
use rustc::lint::*;
54
use std::collections::HashSet;
65
use syntax::ast;
@@ -184,8 +183,8 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> {
184183
}
185184
},
186185
hir::ExprMethodCall(_, _, ref args) => {
187-
let method_call = ty::MethodCall::expr(expr.id);
188-
let base_type = self.cx.tables.method_map[&method_call].ty;
186+
let def_id = self.cx.tables.type_dependent_defs[&expr.id].def_id();
187+
let base_type = self.cx.tcx.type_of(def_id);
189188

190189
if type_is_unsafe_function(base_type) {
191190
for arg in args {

clippy_lints/src/len_zero.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fn check_trait_items(cx: &LateContext, item: &Item, trait_items: &[TraitItemRef]
9595
{
9696
let did = cx.tcx.hir.local_def_id(item.id.node_id);
9797
let impl_ty = cx.tcx.type_of(did);
98-
impl_ty.fn_args().skip_binder().len() == 1
98+
impl_ty.fn_sig().inputs().skip_binder().len() == 1
9999
}
100100
} else {
101101
false
@@ -122,7 +122,7 @@ fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItemRef]) {
122122
{
123123
let did = cx.tcx.hir.local_def_id(item.id.node_id);
124124
let impl_ty = cx.tcx.type_of(did);
125-
impl_ty.fn_args().skip_binder().len() == 1
125+
impl_ty.fn_sig().inputs().skip_binder().len() == 1
126126
}
127127
} else {
128128
false

clippy_lints/src/loops.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use rustc::lint::*;
88
use rustc::middle::const_val::ConstVal;
99
use rustc::middle::region::CodeExtent;
1010
use rustc::ty;
11+
use rustc::ty::subst::Subst;
1112
use rustc_const_eval::ConstContext;
1213
use std::collections::HashMap;
1314
use syntax::ast;
@@ -676,13 +677,11 @@ fn check_for_loop_arg(cx: &LateContext, pat: &Pat, arg: &Expr, expr: &Expr) {
676677
lint_iter_method(cx, args, arg, &method_name);
677678
}
678679
} else if method_name == "into_iter" && match_trait_method(cx, arg, &paths::INTO_ITERATOR) {
679-
let method_call = ty::MethodCall::expr(arg.id);
680-
let fn_ty = cx.tables
681-
.method_map
682-
.get(&method_call)
683-
.map(|method_callee| method_callee.ty)
684-
.expect("method calls need an entry in the method map");
685-
let fn_arg_tys = fn_ty.fn_args();
680+
let def_id = cx.tables.type_dependent_defs[&arg.id].def_id();
681+
let substs = cx.tables.node_substs(arg.id);
682+
let method_type = cx.tcx.type_of(def_id).subst(cx.tcx, substs);
683+
684+
let fn_arg_tys = method_type.fn_sig().inputs();
686685
assert_eq!(fn_arg_tys.skip_binder().len(), 1);
687686
if fn_arg_tys.skip_binder()[0].is_region_ptr() {
688687
lint_iter_method(cx, args, arg, &method_name);

clippy_lints/src/mut_reference.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use rustc::lint::*;
2-
use rustc::ty::{TypeAndMut, TypeVariants, MethodCall, TyS};
2+
use rustc::ty::{TypeAndMut, TypeVariants, TyS};
3+
use rustc::ty::subst::Subst;
34
use rustc::hir::*;
45
use utils::span_lint;
56

@@ -34,24 +35,20 @@ impl LintPass for UnnecessaryMutPassed {
3435

3536
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnecessaryMutPassed {
3637
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
37-
let borrowed_table = cx.tables;
3838
match e.node {
3939
ExprCall(ref fn_expr, ref arguments) => {
40-
let function_type = borrowed_table.node_types
41-
.get(&fn_expr.id)
42-
.expect("A function with an unknown type is called. If this happened, the compiler would have \
43-
aborted the compilation long ago");
4440
if let ExprPath(ref path) = fn_expr.node {
4541
check_arguments(cx,
4642
arguments,
47-
function_type,
43+
cx.tables.expr_ty(fn_expr),
4844
&print::to_string(print::NO_ANN, |s| s.print_qpath(path, false)));
4945
}
5046
},
5147
ExprMethodCall(ref name, _, ref arguments) => {
52-
let method_call = MethodCall::expr(e.id);
53-
let method_type = borrowed_table.method_map.get(&method_call).expect("This should never happen.");
54-
check_arguments(cx, arguments, method_type.ty, &name.node.as_str())
48+
let def_id = cx.tables.type_dependent_defs[&e.id].def_id();
49+
let substs = cx.tables.node_substs(e.id);
50+
let method_type = cx.tcx.type_of(def_id).subst(cx.tcx, substs);
51+
check_arguments(cx, arguments, method_type, &name.node.as_str())
5552
},
5653
_ => (),
5754
}
@@ -71,7 +68,7 @@ fn check_arguments(cx: &LateContext, arguments: &[Expr], type_definition: &TyS,
7168
span_lint(cx,
7269
UNNECESSARY_MUT_PASSED,
7370
argument.span,
74-
&format!("The function/method \"{}\" doesn't need a mutable reference", name));
71+
&format!("The function/method `{}` doesn't need a mutable reference", name));
7572
}
7673
},
7774
_ => (),

clippy_lints/src/needless_borrow.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use rustc::lint::*;
66
use rustc::hir::{ExprAddrOf, Expr, MutImmutable, Pat, PatKind, BindingMode};
77
use rustc::ty;
8+
use rustc::ty::adjustment::{Adjustment, Adjust};
89
use utils::{span_lint, in_macro};
910

1011
/// **What it does:** Checks for address of operations (`&`) that are going to
@@ -41,9 +42,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow {
4142
}
4243
if let ExprAddrOf(MutImmutable, ref inner) = e.node {
4344
if let ty::TyRef(..) = cx.tables.expr_ty(inner).sty {
44-
if let Some(&ty::adjustment::Adjust::DerefRef { autoderefs, autoref, .. }) =
45-
cx.tables.adjustments.get(&e.id).map(|a| &a.kind) {
46-
if autoderefs > 1 && autoref.is_some() {
45+
for adj3 in cx.tables.expr_adjustments(e).windows(3) {
46+
if let [
47+
Adjustment { kind: Adjust::Deref(_), .. },
48+
Adjustment { kind: Adjust::Deref(_), .. },
49+
Adjustment { kind: Adjust::Borrow(_), .. }
50+
] = *adj3 {
4751
span_lint(cx,
4852
NEEDLESS_BORROW,
4953
e.span,

0 commit comments

Comments
 (0)