Skip to content

Commit

Permalink
rustup, fix breakage introduced by rust-lang/rust#53581
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskrgr committed Aug 22, 2018
1 parent f05a103 commit 712d2d4
Show file tree
Hide file tree
Showing 38 changed files with 158 additions and 157 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/bytecount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ByteCount {
_ => { return; }
}
};
if ty::TyUint(UintTy::U8) != walk_ptrs_ty(cx.tables.expr_ty(needle)).sty {
if ty::Uint(UintTy::U8) != walk_ptrs_ty(cx.tables.expr_ty(needle)).sty {
return;
}
let haystack = if let ExprKind::MethodCall(ref path, _, ref args) =
Expand Down
32 changes: 16 additions & 16 deletions clippy_lints/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ impl Hash for Constant {
}

impl Constant {
pub fn partial_cmp(tcx: TyCtxt<'_, '_, '_>, cmp_type: &ty::TypeVariants<'_>, left: &Self, right: &Self) -> Option<Ordering> {
pub fn partial_cmp(tcx: TyCtxt<'_, '_, '_>, cmp_type: &ty::TyKind<'_>, left: &Self, right: &Self) -> Option<Ordering> {
match (left, right) {
(&Constant::Str(ref ls), &Constant::Str(ref rs)) => Some(ls.cmp(rs)),
(&Constant::Char(ref l), &Constant::Char(ref r)) => Some(l.cmp(r)),
(&Constant::Int(l), &Constant::Int(r)) => {
if let ty::TyInt(int_ty) = *cmp_type {
if let ty::Int(int_ty) = *cmp_type {
Some(sext(tcx, l, int_ty).cmp(&sext(tcx, r, int_ty)))
} else {
Some(l.cmp(&r))
Expand Down Expand Up @@ -166,8 +166,8 @@ pub fn lit_to_constant<'tcx>(lit: &LitKind, ty: Ty<'tcx>) -> Constant {
LitKind::Int(n, _) => Constant::Int(n),
LitKind::Float(ref is, _) |
LitKind::FloatUnsuffixed(ref is) => match ty.sty {
ty::TyFloat(FloatTy::F32) => Constant::F32(is.as_str().parse().unwrap()),
ty::TyFloat(FloatTy::F64) => Constant::F64(is.as_str().parse().unwrap()),
ty::Float(FloatTy::F32) => Constant::F32(is.as_str().parse().unwrap()),
ty::Float(FloatTy::F64) => Constant::F64(is.as_str().parse().unwrap()),
_ => bug!(),
},
LitKind::Bool(b) => Constant::Bool(b),
Expand Down Expand Up @@ -220,7 +220,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
ExprKind::Tup(ref tup) => self.multi(tup).map(Constant::Tuple),
ExprKind::Repeat(ref value, _) => {
let n = match self.tables.expr_ty(e).sty {
ty::TyArray(_, n) => n.assert_usize(self.tcx).expect("array length"),
ty::Array(_, n) => n.assert_usize(self.tcx).expect("array length"),
_ => span_bug!(e.span, "typeck error"),
};
self.expr(value).map(|v| Constant::Repeat(Box::new(v), n as u64))
Expand All @@ -243,8 +243,8 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
Int(value) => {
let value = !value;
match ty.sty {
ty::TyInt(ity) => Some(Int(unsext(self.tcx, value as i128, ity))),
ty::TyUint(ity) => Some(Int(clip(self.tcx, value, ity))),
ty::Int(ity) => Some(Int(unsext(self.tcx, value as i128, ity))),
ty::Uint(ity) => Some(Int(clip(self.tcx, value, ity))),
_ => None,
}
},
Expand All @@ -257,7 +257,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
match *o {
Int(value) => {
let ity = match ty.sty {
ty::TyInt(ity) => ity,
ty::Int(ity) => ity,
_ => return None,
};
// sign extend
Expand Down Expand Up @@ -336,7 +336,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
match (l, r) {
(Constant::Int(l), Some(Constant::Int(r))) => {
match self.tables.expr_ty(left).sty {
ty::TyInt(ity) => {
ty::Int(ity) => {
let l = sext(self.tcx, l, ity);
let r = sext(self.tcx, r, ity);
let zext = |n: i128| Constant::Int(unsext(self.tcx, n, ity));
Expand All @@ -360,7 +360,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
_ => None,
}
}
ty::TyUint(_) => {
ty::Uint(_) => {
match op.node {
BinOpKind::Add => l.checked_add(r).map(Constant::Int),
BinOpKind::Sub => l.checked_sub(r).map(Constant::Int),
Expand Down Expand Up @@ -429,18 +429,18 @@ pub fn miri_to_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, result: &ty::Const<'
use rustc::mir::interpret::{Scalar, ScalarMaybeUndef, ConstValue};
match result.val {
ConstValue::Scalar(Scalar::Bits{ bits: b, ..}) => match result.ty.sty {
ty::TyBool => Some(Constant::Bool(b == 1)),
ty::TyUint(_) | ty::TyInt(_) => Some(Constant::Int(b)),
ty::TyFloat(FloatTy::F32) => Some(Constant::F32(f32::from_bits(b as u32))),
ty::TyFloat(FloatTy::F64) => Some(Constant::F64(f64::from_bits(b as u64))),
ty::Bool => Some(Constant::Bool(b == 1)),
ty::Uint(_) | ty::Int(_) => Some(Constant::Int(b)),
ty::Float(FloatTy::F32) => Some(Constant::F32(f32::from_bits(b as u32))),
ty::Float(FloatTy::F64) => Some(Constant::F64(f64::from_bits(b as u64))),
// FIXME: implement other conversion
_ => None,
},
ConstValue::ScalarPair(Scalar::Ptr(ptr),
ScalarMaybeUndef::Scalar(
Scalar::Bits { bits: n, .. })) => match result.ty.sty {
ty::TyRef(_, tam, _) => match tam.sty {
ty::TyStr => {
ty::Ref(_, tam, _) => match tam.sty {
ty::Str => {
let alloc = tcx
.alloc_map
.lock()
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/cyclomatic_complexity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ impl<'a, 'tcx> Visitor<'tcx> for CCHelper<'a, 'tcx> {
walk_expr(self, e);
let ty = self.cx.tables.node_id_to_type(callee.hir_id);
match ty.sty {
ty::TyFnDef(..) | ty::TyFnPtr(_) => {
ty::FnDef(..) | ty::FnPtr(_) => {
let sig = ty.fn_sig(self.cx.tcx);
if sig.skip_binder().output().sty == ty::TyNever {
if sig.skip_binder().output().sty == ty::Never {
self.divergence += 1;
}
},
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/default_trait_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use if_chain::if_chain;
use rustc::ty::TypeVariants;
use rustc::ty::TyKind;

use crate::utils::{any_parent_is_automatically_derived, match_def_path, opt_def_id, paths, span_lint_and_sugg};

Expand Down Expand Up @@ -51,7 +51,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DefaultTraitAccess {
// TODO: Work out a way to put "whatever the imported way of referencing
// this type in this file" rather than a fully-qualified type.
let expr_ty = cx.tables.expr_ty(expr);
if let TypeVariants::TyAdt(..) = expr_ty.sty {
if let TyKind::Adt(..) = expr_ty.sty {
let replacement = format!("{}::default()", expr_ty);
span_lint_and_sugg(
cx,
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,18 @@ fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item, trait_ref
}

match ty.sty {
ty::TyAdt(def, _) if def.is_union() => return,
ty::Adt(def, _) if def.is_union() => return,

// Some types are not Clone by default but could be cloned “by hand” if necessary
ty::TyAdt(def, substs) => for variant in &def.variants {
ty::Adt(def, substs) => for variant in &def.variants {
for field in &variant.fields {
if let ty::TyFnDef(..) = field.ty(cx.tcx, substs).sty {
if let ty::FnDef(..) = field.ty(cx.tcx, substs).sty {
return;
}
}
for subst in substs {
if let ty::subst::UnpackedKind::Type(subst) = subst.unpack() {
if let ty::TyParam(_) = subst.sty {
if let ty::Param(_) = subst.sty {
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/drop_forget_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
let arg = &args[0];
let arg_ty = cx.tables.expr_ty(arg);

if let ty::TyRef(..) = arg_ty.sty {
if let ty::Ref(..) = arg_ty.sty {
if match_def_path(cx.tcx, def_id, &paths::DROP) {
lint = DROP_REF;
msg = DROP_REF_SUMMARY.to_string();
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/enum_clike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,19 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
let constant = cx.tcx.const_eval(param_env.and(cid)).ok();
if let Some(Constant::Int(val)) = constant.and_then(|c| miri_to_const(cx.tcx, c)) {
let mut ty = cx.tcx.type_of(did);
if let ty::TyAdt(adt, _) = ty.sty {
if let ty::Adt(adt, _) = ty.sty {
if adt.is_enum() {
ty = adt.repr.discr_type().to_ty(cx.tcx);
}
}
match ty.sty {
ty::TyInt(IntTy::Isize) => {
ty::Int(IntTy::Isize) => {
let val = ((val as i128) << 64) >> 64;
if val <= i128::from(i32::max_value()) && val >= i128::from(i32::min_value()) {
continue;
}
}
ty::TyUint(UintTy::Usize) if val > u128::from(u32::max_value()) => {},
ty::Uint(UintTy::Usize) if val > u128::from(u32::max_value()) => {},
_ => continue,
}
span_lint(
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/eta_reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ fn check_closure(cx: &LateContext<'_, '_>, expr: &Expr) {
let fn_ty = cx.tables.expr_ty(caller);
match fn_ty.sty {
// Is it an unsafe function? They don't implement the closure traits
ty::TyFnDef(..) | ty::TyFnPtr(_) => {
ty::FnDef(..) | ty::FnPtr(_) => {
let sig = fn_ty.fn_sig(cx.tcx);
if sig.skip_binder().unsafety == Unsafety::Unsafe || sig.skip_binder().output().sty == ty::TyNever {
if sig.skip_binder().unsafety == Unsafety::Unsafe || sig.skip_binder().output().sty == ty::Never {
return;
}
},
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/eval_order_dependence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
ExprKind::Call(ref func, _) => {
let typ = self.cx.tables.expr_ty(func);
match typ.sty {
ty::TyFnDef(..) | ty::TyFnPtr(_) => {
ty::FnDef(..) | ty::FnPtr(_) => {
let sig = typ.fn_sig(self.cx.tcx);
if let ty::TyNever = self.cx.tcx.erase_late_bound_regions(&sig).output().sty {
if let ty::Never = self.cx.tcx.erase_late_bound_regions(&sig).output().sty {
self.report_diverging_sub_expr(e);
}
},
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/excessive_precision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use rustc::hir;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use if_chain::if_chain;
use rustc::ty::TypeVariants;
use rustc::ty::TyKind;
use std::f32;
use std::f64;
use std::fmt;
Expand Down Expand Up @@ -46,7 +46,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExcessivePrecision {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
if_chain! {
let ty = cx.tables.expr_ty(expr);
if let TypeVariants::TyFloat(fty) = ty.sty;
if let TyKind::Float(fty) = ty.sty;
if let hir::ExprKind::Lit(ref lit) = expr.node;
if let LitKind::Float(sym, _) | LitKind::FloatUnsuffixed(sym) = lit.node;
if let Some(sugg) = self.check(sym, fty);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/fallible_impl_from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_it

fn match_type(tcx: ty::TyCtxt<'_, '_, '_>, ty: ty::Ty<'_>, path: &[&str]) -> bool {
match ty.sty {
ty::TyAdt(adt, _) => match_def_path(tcx, adt.did, path),
ty::Adt(adt, _) => match_def_path(tcx, adt.did, path),
_ => false,
}
}
2 changes: 1 addition & 1 deletion clippy_lints/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ fn get_single_string_arg(cx: &LateContext<'_, '_>, expr: &Expr) -> Option<Span>
if match_def_path(cx.tcx, fun_def_id, &paths::DISPLAY_FMT_METHOD);
then {
let ty = walk_ptrs_ty(cx.tables.pat_ty(&pat[0]));
if ty.sty == ty::TyStr || match_type(cx, ty, &paths::STRING) {
if ty.sty == ty::Str || match_type(cx, ty, &paths::STRING) {
if let ExprKind::Tup(ref values) = match_expr.node {
return Some(values[0].span);
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/identity_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityOp {
fn check(cx: &LateContext<'_, '_>, e: &Expr, m: i8, span: Span, arg: Span) {
if let Some(Constant::Int(v)) = constant_simple(cx, cx.tables, e) {
let check = match cx.tables.expr_ty(e).sty {
ty::TyInt(ity) => unsext(cx.tcx, -1_i128, ity),
ty::TyUint(uty) => clip(cx.tcx, !0, uty),
ty::Int(ity) => unsext(cx.tcx, -1_i128, ity),
ty::Uint(uty) => clip(cx.tcx, !0, uty),
_ => return,
};
if match m {
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/indexing_slicing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing {
let ty = cx.tables.expr_ty(array);
if let Some(range) = higher::range(cx, index) {
// Ranged indexes, i.e. &x[n..m], &x[n..], &x[..n] and &x[..]
if let ty::TyArray(_, s) = ty.sty {
if let ty::Array(_, s) = ty.sty {
let size: u128 = s.assert_usize(cx.tcx).unwrap().into();
// Index is a constant range.
if let Some((start, end)) = to_const_range(cx, range, size) {
Expand Down Expand Up @@ -131,7 +131,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing {
);
} else {
// Catchall non-range index, i.e. [n] or [n << m]
if let ty::TyArray(..) = ty.sty {
if let ty::Array(..) = ty.sty {
// Index is a constant uint.
if let Some(..) = constant(cx, cx.tables, index) {
// Let rustc's `const_err` lint handle constant `usize` indexing on arrays.
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/invalid_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidRef {
if let ExprKind::Call(ref path, ref args) = expr.node;
if let ExprKind::Path(ref qpath) = path.node;
if args.len() == 0;
if let ty::TyRef(..) = cx.tables.expr_ty(expr).sty;
if let ty::Ref(..) = cx.tables.expr_ty(expr).sty;
if let Some(def_id) = opt_def_id(cx.tables.qpath_def(qpath, path.hir_id));
then {
let msg = if match_def_path(cx.tcx, def_id, &paths::MEM_ZEROED) |
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/len_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,12 @@ fn has_is_empty(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {

let ty = &walk_ptrs_ty(cx.tables.expr_ty(expr));
match ty.sty {
ty::TyDynamic(ref tt, ..) => cx.tcx
ty::Dynamic(ref tt, ..) => cx.tcx
.associated_items(tt.principal().expect("trait impl not found").def_id())
.any(|item| is_is_empty(cx, &item)),
ty::TyProjection(ref proj) => has_is_empty_impl(cx, proj.item_def_id),
ty::TyAdt(id, _) => has_is_empty_impl(cx, id.did),
ty::TyArray(..) | ty::TySlice(..) | ty::TyStr => true,
ty::Projection(ref proj) => has_is_empty_impl(cx, proj.item_def_id),
ty::Adt(id, _) => has_is_empty_impl(cx, id.did),
ty::Array(..) | ty::Slice(..) | ty::Str => true,
_ => false,
}
}
18 changes: 9 additions & 9 deletions clippy_lints/src/loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,8 +759,8 @@ struct FixedOffsetVar {

fn is_slice_like<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'_>) -> bool {
let is_slice = match ty.sty {
ty::TyRef(_, subty, _) => is_slice_like(cx, subty),
ty::TySlice(..) | ty::TyArray(..) => true,
ty::Ref(_, subty, _) => is_slice_like(cx, subty),
ty::Slice(..) | ty::Array(..) => true,
_ => false,
};

Expand Down Expand Up @@ -1149,8 +1149,8 @@ fn check_for_loop_reverse_range<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, arg: &'tcx
Constant::Int(start_idx),
Constant::Int(end_idx),
) => (match ty.sty {
ty::TyInt(ity) => sext(cx.tcx, start_idx, ity) > sext(cx.tcx, end_idx, ity),
ty::TyUint(_) => start_idx > end_idx,
ty::Int(ity) => sext(cx.tcx, start_idx, ity) > sext(cx.tcx, end_idx, ity),
ty::Uint(_) => start_idx > end_idx,
_ => false,
}, start_idx == end_idx),
_ => (false, false),
Expand Down Expand Up @@ -1239,7 +1239,7 @@ fn check_for_loop_arg(cx: &LateContext<'_, '_>, pat: &Pat, arg: &Expr, expr: &Ex
match cx.tables.expr_ty(&args[0]).sty {
// If the length is greater than 32 no traits are implemented for array and
// therefore we cannot use `&`.
ty::TypeVariants::TyArray(_, size) if size.assert_usize(cx.tcx).expect("array size") > 32 => (),
ty::TyKind::Array(_, size) if size.assert_usize(cx.tcx).expect("array size") > 32 => (),
_ => lint_iter_method(cx, args, arg, method_name),
};
} else {
Expand Down Expand Up @@ -1381,7 +1381,7 @@ fn check_for_loop_over_map_kv<'a, 'tcx>(
if pat.len() == 2 {
let arg_span = arg.span;
let (new_pat_span, kind, ty, mutbl) = match cx.tables.expr_ty(arg).sty {
ty::TyRef(_, ty, mutbl) => match (&pat[0].node, &pat[1].node) {
ty::Ref(_, ty, mutbl) => match (&pat[0].node, &pat[1].node) {
(key, _) if pat_is_wild(key, body) => (pat[1].span, "value", ty, mutbl),
(_, value) if pat_is_wild(value, body) => (pat[0].span, "key", ty, MutImmutable),
_ => return,
Expand Down Expand Up @@ -1721,7 +1721,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
for expr in args {
let ty = self.cx.tables.expr_ty_adjusted(expr);
self.prefer_mutable = false;
if let ty::TyRef(_, _, mutbl) = ty.sty {
if let ty::Ref(_, _, mutbl) = ty.sty {
if mutbl == MutMutable {
self.prefer_mutable = true;
}
Expand All @@ -1733,7 +1733,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
let def_id = self.cx.tables.type_dependent_defs()[expr.hir_id].def_id();
for (ty, expr) in self.cx.tcx.fn_sig(def_id).inputs().skip_binder().iter().zip(args) {
self.prefer_mutable = false;
if let ty::TyRef(_, _, mutbl) = ty.sty {
if let ty::Ref(_, _, mutbl) = ty.sty {
if mutbl == MutMutable {
self.prefer_mutable = true;
}
Expand Down Expand Up @@ -1814,7 +1814,7 @@ fn is_ref_iterable_type(cx: &LateContext<'_, '_>, e: &Expr) -> bool {
fn is_iterable_array(ty: Ty<'_>, cx: &LateContext<'_, '_>) -> bool {
// IntoIterator is currently only implemented for array sizes <= 32 in rustc
match ty.sty {
ty::TyArray(_, n) => (0..=32).contains(&n.assert_usize(cx.tcx).expect("array length")),
ty::Array(_, n) => (0..=32).contains(&n.assert_usize(cx.tcx).expect("array length")),
_ => false,
}
}
Expand Down
Loading

0 comments on commit 712d2d4

Please sign in to comment.