Skip to content

Commit c5de91c

Browse files
committed
How to NOT solve rust-lang#2788
Seriously this workaround is terrible, don't merge it
1 parent 3c6503e commit c5de91c

File tree

10 files changed

+39
-37
lines changed

10 files changed

+39
-37
lines changed

clippy_lints/src/assign_ops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
174174
op.node,
175175
cx,
176176
ty,
177-
rty,
177+
rty.into(),
178178
Add: BiAdd,
179179
Sub: BiSub,
180180
Mul: BiMul,

clippy_lints/src/consts.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,9 @@ pub fn miri_to_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, result: &ty::Const<'
429429
ty::TyRef(_, tam, _) => match tam.sty {
430430
ty::TyStr => {
431431
let alloc = tcx
432-
.interpret_interner
433-
.get_alloc(ptr.alloc_id)
434-
.unwrap();
432+
.alloc_map
433+
.lock()
434+
.unwrap_memory(ptr.alloc_id);
435435
let offset = ptr.offset.bytes() as usize;
436436
let n = n as usize;
437437
String::from_utf8(alloc.bytes[offset..(offset + n)].to_owned()).ok().map(Constant::Str)

clippy_lints/src/enum_clike.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
5050
if let ItemEnum(ref def, _) = item.node {
5151
for var in &def.variants {
5252
let variant = &var.node;
53-
if let Some(body_id) = variant.disr_expr {
53+
if let Some(ref anon_const) = variant.disr_expr {
5454
let param_env = ty::ParamEnv::empty();
55-
let did = cx.tcx.hir.body_owner_def_id(body_id);
55+
let did = cx.tcx.hir.body_owner_def_id(anon_const.body);
5656
let substs = Substs::identity_for_item(cx.tcx.global_tcx(), did);
5757
let instance = ty::Instance::new(did, substs);
5858
let cid = GlobalId {

clippy_lints/src/eq_op.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
9090
let lcpy = is_copy(cx, lty);
9191
let rcpy = is_copy(cx, rty);
9292
// either operator autorefs or both args are copyable
93-
if (requires_ref || (lcpy && rcpy)) && implements_trait(cx, lty, trait_id, &[rty]) {
93+
if (requires_ref || (lcpy && rcpy)) && implements_trait(cx, lty, trait_id, &[rty.into()]) {
9494
span_lint_and_then(
9595
cx,
9696
OP_REF,
@@ -106,12 +106,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
106106
);
107107
},
108108
)
109-
} else if lcpy && !rcpy && implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right)]) {
109+
} else if lcpy && !rcpy && implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right).into()]) {
110110
span_lint_and_then(cx, OP_REF, e.span, "needlessly taken reference of left operand", |db| {
111111
let lsnip = snippet(cx, l.span, "...").to_string();
112112
db.span_suggestion(left.span, "use the left value directly", lsnip);
113113
})
114-
} else if !lcpy && rcpy && implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty]) {
114+
} else if !lcpy && rcpy && implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty.into()]) {
115115
span_lint_and_then(
116116
cx,
117117
OP_REF,
@@ -128,7 +128,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
128128
(&ExprAddrOf(_, ref l), _) => {
129129
let lty = cx.tables.expr_ty(l);
130130
let lcpy = is_copy(cx, lty);
131-
if (requires_ref || lcpy) && implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right)]) {
131+
if (requires_ref || lcpy) && implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right).into()]) {
132132
span_lint_and_then(cx, OP_REF, e.span, "needlessly taken reference of left operand", |db| {
133133
let lsnip = snippet(cx, l.span, "...").to_string();
134134
db.span_suggestion(left.span, "use the left value directly", lsnip);
@@ -139,7 +139,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
139139
(_, &ExprAddrOf(_, ref r)) => {
140140
let rty = cx.tables.expr_ty(r);
141141
let rcpy = is_copy(cx, rty);
142-
if (requires_ref || rcpy) && implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty]) {
142+
if (requires_ref || rcpy) && implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty.into()]) {
143143
span_lint_and_then(cx, OP_REF, e.span, "taken reference of right operand", |db| {
144144
let rsnip = snippet(cx, r.span, "...").to_string();
145145
db.span_suggestion(right.span, "use the right value directly", rsnip);

clippy_lints/src/misc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,13 +495,13 @@ fn check_to_owned(cx: &LateContext, expr: &Expr, other: &Expr) {
495495
// *arg impls PartialEq<other>
496496
if !arg_ty
497497
.builtin_deref(true)
498-
.map_or(false, |tam| implements_trait(cx, tam.ty, partial_eq_trait_id, &[other_ty]))
498+
.map_or(false, |tam| implements_trait(cx, tam.ty, partial_eq_trait_id, &[other_ty.into()]))
499499
// arg impls PartialEq<*other>
500500
&& !other_ty
501501
.builtin_deref(true)
502-
.map_or(false, |tam| implements_trait(cx, arg_ty, partial_eq_trait_id, &[tam.ty]))
502+
.map_or(false, |tam| implements_trait(cx, arg_ty, partial_eq_trait_id, &[tam.ty.into()]))
503503
// arg impls PartialEq<other>
504-
&& !implements_trait(cx, arg_ty, partial_eq_trait_id, &[other_ty])
504+
&& !implements_trait(cx, arg_ty, partial_eq_trait_id, &[other_ty.into()])
505505
{
506506
return;
507507
}

clippy_lints/src/needless_pass_by_value.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
175175
cx,
176176
cx.tcx.mk_imm_ref(&RegionKind::ReErased, ty),
177177
t.def_id(),
178-
&t.skip_binder().input_types().skip(1).collect::<Vec<_>>(),
178+
// What an ugly abomination
179+
&t.skip_binder().input_types().skip(1).collect::<Vec<_>>()
180+
.into_iter().map(|ty| ty.into()).collect::<Vec<_>>(),
179181
)
180182
}),
181183
)

clippy_lints/src/shadow.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,15 +348,15 @@ fn check_expr<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, bindings:
348348
fn check_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: &'tcx Ty, bindings: &mut Vec<(Name, Span)>) {
349349
match ty.node {
350350
TySlice(ref sty) => check_ty(cx, sty, bindings),
351-
TyArray(ref fty, body_id) => {
351+
TyArray(ref fty, ref body_id) => {
352352
check_ty(cx, fty, bindings);
353-
check_expr(cx, &cx.tcx.hir.body(body_id).value, bindings);
353+
check_expr(cx, &cx.tcx.hir.body(body_id.body).value, bindings);
354354
},
355355
TyPtr(MutTy { ty: ref mty, .. }) | TyRptr(_, MutTy { ty: ref mty, .. }) => check_ty(cx, mty, bindings),
356356
TyTup(ref tup) => for t in tup {
357357
check_ty(cx, t, bindings)
358358
},
359-
TyTypeof(body_id) => check_expr(cx, &cx.tcx.hir.body(body_id).value, bindings),
359+
TyTypeof(ref body_id) => check_expr(cx, &cx.tcx.hir.body(body_id.body).value, bindings),
360360
_ => (),
361361
}
362362
}

clippy_lints/src/utils/hir_utils.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
120120
(&ExprMethodCall(ref l_path, _, ref l_args), &ExprMethodCall(ref r_path, _, ref r_args)) => {
121121
!self.ignore_fn && l_path == r_path && self.eq_exprs(l_args, r_args)
122122
},
123-
(&ExprRepeat(ref le, ll_id), &ExprRepeat(ref re, rl_id)) => {
124-
let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(ll_id));
125-
let ll = celcx.expr(&self.cx.tcx.hir.body(ll_id).value);
126-
let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(rl_id));
127-
let rl = celcx.expr(&self.cx.tcx.hir.body(rl_id).value);
123+
(&ExprRepeat(ref le, ref ll_id), &ExprRepeat(ref re, ref rl_id)) => {
124+
let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(ll_id.body));
125+
let ll = celcx.expr(&self.cx.tcx.hir.body(ll_id.body).value);
126+
let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(rl_id.body));
127+
let rl = celcx.expr(&self.cx.tcx.hir.body(rl_id.body).value);
128128

129129
self.eq_expr(le, re) && ll == rl
130130
},
@@ -234,16 +234,16 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
234234
fn eq_ty(&mut self, left: &Ty, right: &Ty) -> bool {
235235
match (&left.node, &right.node) {
236236
(&TySlice(ref l_vec), &TySlice(ref r_vec)) => self.eq_ty(l_vec, r_vec),
237-
(&TyArray(ref lt, ll_id), &TyArray(ref rt, rl_id)) => {
237+
(&TyArray(ref lt, ref ll_id), &TyArray(ref rt, ref rl_id)) => {
238238
let full_table = self.tables;
239239

240-
let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(ll_id));
241-
self.tables = self.cx.tcx.body_tables(ll_id);
242-
let ll = celcx.expr(&self.cx.tcx.hir.body(ll_id).value);
240+
let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(ll_id.body));
241+
self.tables = self.cx.tcx.body_tables(ll_id.body);
242+
let ll = celcx.expr(&self.cx.tcx.hir.body(ll_id.body).value);
243243

244-
let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(rl_id));
245-
self.tables = self.cx.tcx.body_tables(rl_id);
246-
let rl = celcx.expr(&self.cx.tcx.hir.body(rl_id).value);
244+
let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(rl_id.body));
245+
self.tables = self.cx.tcx.body_tables(rl_id.body);
246+
let rl = celcx.expr(&self.cx.tcx.hir.body(rl_id.body).value);
247247

248248
let eq_ty = self.eq_ty(lt, rt);
249249
self.tables = full_table;
@@ -474,13 +474,13 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
474474
self.hash_name(&path.name);
475475
self.hash_exprs(args);
476476
},
477-
ExprRepeat(ref e, l_id) => {
477+
ExprRepeat(ref e, ref l_id) => {
478478
let c: fn(_, _) -> _ = ExprRepeat;
479479
c.hash(&mut self.s);
480480
self.hash_expr(e);
481481
let full_table = self.tables;
482-
self.tables = self.cx.tcx.body_tables(l_id);
483-
self.hash_expr(&self.cx.tcx.hir.body(l_id).value);
482+
self.tables = self.cx.tcx.body_tables(l_id.body);
483+
self.hash_expr(&self.cx.tcx.hir.body(l_id.body).value);
484484
self.tables = full_table;
485485
},
486486
ExprRet(ref e) => {

clippy_lints/src/utils/inspector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,12 @@ fn print_expr(cx: &LateContext, expr: &hir::Expr, indent: usize) {
330330
print_expr(cx, base, indent + 1);
331331
}
332332
},
333-
hir::ExprRepeat(ref val, body_id) => {
333+
hir::ExprRepeat(ref val, ref anon_const) => {
334334
println!("{}Repeat", ind);
335335
println!("{}value:", ind);
336336
print_expr(cx, val, indent + 1);
337337
println!("{}repeat count:", ind);
338-
print_expr(cx, &cx.tcx.hir.body(body_id).value, indent + 1);
338+
print_expr(cx, &cx.tcx.hir.body(anon_const.body).value, indent + 1);
339339
},
340340
}
341341
}

clippy_lints/src/utils/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc::hir::map::Node;
88
use rustc::lint::{LateContext, Level, Lint, LintContext};
99
use rustc::session::Session;
1010
use rustc::traits;
11-
use rustc::ty::{self, Ty, TyCtxt, layout::{self, IntegerExt}};
11+
use rustc::ty::{self, Ty, TyCtxt, layout::{self, IntegerExt}, subst::Kind};
1212
use rustc_errors::{Applicability, CodeSuggestion, Substitution, SubstitutionPart};
1313
use std::borrow::Cow;
1414
use std::env;
@@ -295,7 +295,7 @@ pub fn implements_trait<'a, 'tcx>(
295295
cx: &LateContext<'a, 'tcx>,
296296
ty: Ty<'tcx>,
297297
trait_id: DefId,
298-
ty_params: &[Ty<'tcx>],
298+
ty_params: &[Kind<'tcx>],
299299
) -> bool {
300300
let ty = cx.tcx.erase_regions(&ty);
301301
let obligation =

0 commit comments

Comments
 (0)