Skip to content

Commit 67cccc5

Browse files
committed
Try to fix compilation error on rustc 1.19.0-nightly (4ed2eda 2017-06-01)
1 parent 892cc28 commit 67cccc5

File tree

9 files changed

+20
-39
lines changed

9 files changed

+20
-39
lines changed

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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,29 +160,29 @@ impl<'a, 'tcx: 'a> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
160160

161161
if let Categorization::Local(lid) = cmt.cat {
162162
if self.set.contains(&lid) {
163-
if let Some(&Adjust::DerefRef { autoderefs, .. }) =
163+
if let Some(&Adjust::Deref(ref overloaded)) =
164164
self.tables
165165
.adjustments
166166
.get(&borrow_id)
167167
.map(|a| &a.kind) {
168168
if LoanCause::AutoRef == loan_cause {
169169
// x.foo()
170-
if autoderefs == 0 {
170+
if overloaded == 0 {
171171
self.set.remove(&lid); // Used without autodereffing (i.e. x.clone())
172172
}
173173
} else {
174174
span_bug!(cmt.span, "Unknown adjusted AutoRef");
175175
}
176176
} else if LoanCause::AddrOf == loan_cause {
177177
// &x
178-
if let Some(&Adjust::DerefRef { autoderefs, .. }) =
178+
if let Some(&Adjust::Deref(ref overloaded)) =
179179
self.tables
180180
.adjustments
181181
.get(&self.tcx
182182
.hir
183183
.get_parent_node(borrow_id))
184184
.map(|a| &a.kind) {
185-
if autoderefs <= 1 {
185+
if overloaded <= 1 {
186186
// foo(&x) where no extra autoreffing is happening
187187
self.set.remove(&lid);
188188
}

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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> {
184184
}
185185
},
186186
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;
187+
let def_id = self.cx.tables.type_dependent_defs[&expr.id].def_id();
188+
let base_type = self.cx.tcx.type_of(def_id);
189189

190190
if type_is_unsafe_function(base_type) {
191191
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: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -676,13 +676,8 @@ fn check_for_loop_arg(cx: &LateContext, pat: &Pat, arg: &Expr, expr: &Expr) {
676676
lint_iter_method(cx, args, arg, &method_name);
677677
}
678678
} 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();
679+
let fn_ty = cx.tables.expr_ty(arg);
680+
let fn_arg_tys = fn_ty.fn_sig().inputs();
686681
assert_eq!(fn_arg_tys.skip_binder().len(), 1);
687682
if fn_arg_tys.skip_binder()[0].is_region_ptr() {
688683
lint_iter_method(cx, args, arg, &method_name);

clippy_lints/src/mut_reference.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rustc::lint::*;
2-
use rustc::ty::{TypeAndMut, TypeVariants, MethodCall, TyS};
2+
use rustc::ty::{TypeAndMut, TypeVariants, TyS};
33
use rustc::hir::*;
44
use utils::span_lint;
55

@@ -49,9 +49,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnecessaryMutPassed {
4949
}
5050
},
5151
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())
52+
let method_type = borrowed_table.expr_ty(e);
53+
check_arguments(cx, arguments, method_type, &name.node.as_str())
5554
},
5655
_ => (),
5756
}

clippy_lints/src/needless_borrow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow {
4141
}
4242
if let ExprAddrOf(MutImmutable, ref inner) = e.node {
4343
if let ty::TyRef(..) = cx.tables.expr_ty(inner).sty {
44-
if let Some(&ty::adjustment::Adjust::DerefRef { autoderefs, autoref, .. }) =
44+
if let Some(&ty::adjustment::Adjust::Deref(ref overloaded)) =
4545
cx.tables.adjustments.get(&e.id).map(|a| &a.kind) {
4646
if autoderefs > 1 && autoref.is_some() {
4747
span_lint(cx,

clippy_lints/src/utils/mod.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,8 @@ pub fn match_type(cx: &LateContext, ty: ty::Ty, path: &[&str]) -> bool {
184184

185185
/// Check if the method call given in `expr` belongs to given type.
186186
pub fn match_impl_method(cx: &LateContext, expr: &Expr, path: &[&str]) -> bool {
187-
let method_call = ty::MethodCall::expr(expr.id);
188-
189-
let trt_id = cx.tables
190-
.method_map
191-
.get(&method_call)
192-
.and_then(|callee| cx.tcx.impl_of_method(callee.def_id));
187+
let method_call = cx.tables.type_dependent_defs[&expr.id];
188+
let trt_id = cx.tcx.impl_of_method(method_call.def_id());
193189
if let Some(trt_id) = trt_id {
194190
match_def_path(cx.tcx, trt_id, path)
195191
} else {
@@ -199,12 +195,8 @@ pub fn match_impl_method(cx: &LateContext, expr: &Expr, path: &[&str]) -> bool {
199195

200196
/// Check if the method call given in `expr` belongs to given trait.
201197
pub fn match_trait_method(cx: &LateContext, expr: &Expr, path: &[&str]) -> bool {
202-
let method_call = ty::MethodCall::expr(expr.id);
203-
204-
let trt_id = cx.tables
205-
.method_map
206-
.get(&method_call)
207-
.and_then(|callee| cx.tcx.trait_of_item(callee.def_id));
198+
let method_call = cx.tables.type_dependent_defs[&expr.id];
199+
let trt_id = cx.tcx.trait_of_item(method_call.def_id());
208200
if let Some(trt_id) = trt_id {
209201
match_def_path(cx.tcx, trt_id, path)
210202
} else {

0 commit comments

Comments
 (0)