Skip to content

Rustup rust-lang/rust#64513 #4580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clippy_lints/src/bytecount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ByteCount {
_ => { return; }
}
};
if ty::Uint(UintTy::U8) != walk_ptrs_ty(cx.tables.expr_ty(needle)).sty {
if ty::Uint(UintTy::U8) != walk_ptrs_ty(cx.tables.expr_ty(needle)).kind {
return;
}
let haystack = if let ExprKind::MethodCall(ref path, _, ref args) =
Expand Down
20 changes: 10 additions & 10 deletions clippy_lints/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl Constant {
(&Self::Str(ref ls), &Self::Str(ref rs)) => Some(ls.cmp(rs)),
(&Self::Char(ref l), &Self::Char(ref r)) => Some(l.cmp(r)),
(&Self::Int(l), &Self::Int(r)) => {
if let ty::Int(int_ty) = cmp_type.sty {
if let ty::Int(int_ty) = cmp_type.kind {
Some(sext(tcx, l, int_ty).cmp(&sext(tcx, r, int_ty)))
} else {
Some(l.cmp(&r))
Expand Down Expand Up @@ -161,7 +161,7 @@ pub fn lit_to_constant(lit: &LitKind, ty: Ty<'_>) -> Constant {
LitKind::ByteStr(ref s) => Constant::Binary(Lrc::clone(s)),
LitKind::Char(c) => Constant::Char(c),
LitKind::Int(n, _) => Constant::Int(n),
LitKind::Float(ref is, _) | LitKind::FloatUnsuffixed(ref is) => match ty.sty {
LitKind::Float(ref is, _) | LitKind::FloatUnsuffixed(ref is) => match ty.kind {
ty::Float(FloatTy::F32) => Constant::F32(is.as_str().parse().unwrap()),
ty::Float(FloatTy::F64) => Constant::F64(is.as_str().parse().unwrap()),
_ => bug!(),
Expand Down Expand Up @@ -229,7 +229,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
ExprKind::Array(ref vec) => self.multi(vec).map(Constant::Vec),
ExprKind::Tup(ref tup) => self.multi(tup).map(Constant::Tuple),
ExprKind::Repeat(ref value, _) => {
let n = match self.tables.expr_ty(e).sty {
let n = match self.tables.expr_ty(e).kind {
ty::Array(_, n) => n.eval_usize(self.lcx.tcx, self.lcx.param_env),
_ => span_bug!(e.span, "typeck error"),
};
Expand Down Expand Up @@ -286,7 +286,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
Bool(b) => Some(Bool(!b)),
Int(value) => {
let value = !value;
match ty.sty {
match ty.kind {
ty::Int(ity) => Some(Int(unsext(self.lcx.tcx, value as i128, ity))),
ty::Uint(ity) => Some(Int(clip(self.lcx.tcx, value, ity))),
_ => None,
Expand All @@ -300,7 +300,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
use self::Constant::*;
match *o {
Int(value) => {
let ity = match ty.sty {
let ity = match ty.kind {
ty::Int(ity) => ity,
_ => return None,
};
Expand Down Expand Up @@ -378,7 +378,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
let l = self.expr(left)?;
let r = self.expr(right);
match (l, r) {
(Constant::Int(l), Some(Constant::Int(r))) => match self.tables.expr_ty(left).sty {
(Constant::Int(l), Some(Constant::Int(r))) => match self.tables.expr_ty(left).kind {
ty::Int(ity) => {
let l = sext(self.lcx.tcx, l, ity);
let r = sext(self.lcx.tcx, r, ity);
Expand Down Expand Up @@ -470,7 +470,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
pub fn miri_to_const(result: &ty::Const<'_>) -> Option<Constant> {
use rustc::mir::interpret::{ConstValue, Scalar};
match result.val {
ConstValue::Scalar(Scalar::Raw { data: d, .. }) => match result.ty.sty {
ConstValue::Scalar(Scalar::Raw { data: d, .. }) => match result.ty.kind {
ty::Bool => Some(Constant::Bool(d == 1)),
ty::Uint(_) | ty::Int(_) => Some(Constant::Int(d)),
ty::Float(FloatTy::F32) => Some(Constant::F32(f32::from_bits(
Expand All @@ -480,16 +480,16 @@ pub fn miri_to_const(result: &ty::Const<'_>) -> Option<Constant> {
d.try_into().expect("invalid f64 bit representation"),
))),
ty::RawPtr(type_and_mut) => {
if let ty::Uint(_) = type_and_mut.ty.sty {
if let ty::Uint(_) = type_and_mut.ty.kind {
return Some(Constant::RawPtr(d));
}
None
},
// FIXME: implement other conversions.
_ => None,
},
ConstValue::Slice { data, start, end } => match result.ty.sty {
ty::Ref(_, tam, _) => match tam.sty {
ConstValue::Slice { data, start, end } => match result.ty.kind {
ty::Ref(_, tam, _) => match tam.kind {
ty::Str => String::from_utf8(
data.inspect_with_undef_and_ptr_outside_interpreter(start..end)
.to_owned(),
Expand Down
1 change: 0 additions & 1 deletion clippy_lints/src/copies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::ty::Ty;
use rustc::{declare_lint_pass, declare_tool_lint};
use rustc_data_structures::fx::FxHashMap;
use std::cmp::Ordering;
use std::collections::hash_map::Entry;
use std::hash::BuildHasherDefault;
use syntax::symbol::Symbol;
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/default_trait_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,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 ty::Adt(..) = expr_ty.sty {
if let ty::Adt(..) = expr_ty.kind {
let replacement = format!("{}::default()", expr_ty);
span_lint_and_sugg(
cx,
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,20 @@ fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item, trait_ref
return;
}

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

// Some types are not Clone by default but could be cloned “by hand” if necessary
ty::Adt(def, substs) => {
for variant in &def.variants {
for field in &variant.fields {
if let ty::FnDef(..) = field.ty(cx.tcx, substs).sty {
if let ty::FnDef(..) = field.ty(cx.tcx, substs).kind {
return;
}
}
for subst in substs {
if let ty::subst::UnpackedKind::Type(subst) = subst.unpack() {
if let ty::Param(_) = subst.sty {
if let ty::Param(_) = subst.kind {
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 @@ -121,7 +121,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DropForgetRef {
let arg = &args[0];
let arg_ty = cx.tables.expr_ty(arg);

if let ty::Ref(..) = arg_ty.sty {
if let ty::Ref(..) = arg_ty.kind {
if match_def_path(cx, def_id, &paths::DROP) {
lint = DROP_REF;
msg = DROP_REF_SUMMARY.to_string();
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/enum_clike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
let constant = cx.tcx.const_eval(param_env.and(c_id)).ok();
if let Some(Constant::Int(val)) = constant.and_then(miri_to_const) {
let mut ty = cx.tcx.type_of(def_id);
if let ty::Adt(adt, _) = ty.sty {
if let ty::Adt(adt, _) = ty.kind {
if adt.is_enum() {
ty = adt.repr.discr_type().to_ty(cx.tcx);
}
}
match ty.sty {
match ty.kind {
ty::Int(IntTy::Isize) => {
let val = ((val as i128) << 64) >> 64;
if i32::try_from(val).is_ok() {
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/eta_reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fn check_closure(cx: &LateContext<'_, '_>, expr: &Expr) {

let fn_ty = cx.tables.expr_ty(caller);

if matches!(fn_ty.sty, ty::FnDef(_, _) | ty::FnPtr(_) | ty::Closure(_, _));
if matches!(fn_ty.kind, ty::FnDef(_, _) | ty::FnPtr(_) | ty::Closure(_, _));

if !type_is_unsafe_function(cx, fn_ty);

Expand Down Expand Up @@ -171,7 +171,7 @@ fn get_ufcs_type_name(
}

fn match_borrow_depth(lhs: Ty<'_>, rhs: Ty<'_>) -> bool {
match (&lhs.sty, &rhs.sty) {
match (&lhs.kind, &rhs.kind) {
(ty::Ref(_, t1, mut1), ty::Ref(_, t2, mut2)) => mut1 == mut2 && match_borrow_depth(&t1, &t2),
(l, r) => match (l, r) {
(ty::Ref(_, _, _), _) | (_, ty::Ref(_, _, _)) => false,
Expand All @@ -181,7 +181,7 @@ fn match_borrow_depth(lhs: Ty<'_>, rhs: Ty<'_>) -> bool {
}

fn match_types(lhs: Ty<'_>, rhs: Ty<'_>) -> bool {
match (&lhs.sty, &rhs.sty) {
match (&lhs.kind, &rhs.kind) {
(ty::Bool, ty::Bool)
| (ty::Char, ty::Char)
| (ty::Int(_), ty::Int(_))
Expand All @@ -195,7 +195,7 @@ fn match_types(lhs: Ty<'_>, rhs: Ty<'_>) -> bool {
}

fn get_type_name(cx: &LateContext<'_, '_>, ty: Ty<'_>) -> String {
match ty.sty {
match ty.kind {
ty::Adt(t, _) => cx.tcx.def_path_str(t.did),
ty::Ref(_, r, _) => get_type_name(cx, &r),
_ => ty.to_string(),
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 @@ -128,10 +128,10 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
ExprKind::Continue(_) | ExprKind::Break(_, _) | ExprKind::Ret(_) => self.report_diverging_sub_expr(e),
ExprKind::Call(ref func, _) => {
let typ = self.cx.tables.expr_ty(func);
match typ.sty {
match typ.kind {
ty::FnDef(..) | ty::FnPtr(_) => {
let sig = typ.fn_sig(self.cx.tcx);
if let ty::Never = self.cx.tcx.erase_late_bound_regions(&sig).output().sty {
if let ty::Never = self.cx.tcx.erase_late_bound_regions(&sig).output().kind {
self.report_diverging_sub_expr(e);
}
},
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/excessive_precision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,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 ty::Float(fty) = ty.sty;
if let ty::Float(fty) = ty.kind;
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 @@ -123,7 +123,7 @@ fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_it
}

fn match_type(cx: &LateContext<'_, '_>, ty: Ty<'_>, path: &[&str]) -> bool {
match ty.sty {
match ty.kind {
ty::Adt(adt, _) => match_def_path(cx, adt.did, path),
_ => false,
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fn on_argumentv1_new<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, arm
if pats.len() == 1;
then {
let ty = walk_ptrs_ty(cx.tables.pat_ty(&pats[0]));
if ty.sty != rustc::ty::Str && !match_type(cx, ty, &paths::STRING) {
if ty.kind != rustc::ty::Str && !match_type(cx, ty, &paths::STRING) {
return None;
}
if let ExprKind::Lit(ref lit) = format_args.node {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/identity_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityOp {
#[allow(clippy::cast_possible_wrap)]
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 {
let check = match cx.tables.expr_ty(e).kind {
ty::Int(ity) => unsext(cx.tcx, -1_i128, ity),
ty::Uint(uty) => clip(cx.tcx, !0, uty),
_ => return,
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 @@ -93,7 +93,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::Array(_, s) = ty.sty {
if let ty::Array(_, s) = ty.kind {
let size: u128 = s.eval_usize(cx.tcx, cx.param_env).into();

let const_range = to_const_range(cx, range, size);
Expand Down Expand Up @@ -139,7 +139,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing {
utils::span_help_and_lint(cx, INDEXING_SLICING, expr.span, "slicing may panic.", help_msg);
} else {
// Catchall non-range index, i.e., [n] or [n << m]
if let ty::Array(..) = ty.sty {
if let ty::Array(..) = ty.kind {
// 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/len_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ fn has_is_empty(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {
}

let ty = &walk_ptrs_ty(cx.tables.expr_ty(expr));
match ty.sty {
match ty.kind {
ty::Dynamic(ref tt, ..) => {
if let Some(principal) = tt.principal() {
cx.tcx
Expand Down
16 changes: 8 additions & 8 deletions clippy_lints/src/loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ struct FixedOffsetVar {
}

fn is_slice_like<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'_>) -> bool {
let is_slice = match ty.sty {
let is_slice = match ty.kind {
ty::Ref(_, subty, _) => is_slice_like(cx, subty),
ty::Slice(..) | ty::Array(..) => true,
_ => false,
Expand Down Expand Up @@ -1225,7 +1225,7 @@ fn is_end_eq_array_len<'tcx>(
if_chain! {
if let ExprKind::Lit(ref lit) = end.node;
if let ast::LitKind::Int(end_int, _) = lit.node;
if let ty::Array(_, arr_len_const) = indexed_ty.sty;
if let ty::Array(_, arr_len_const) = indexed_ty.kind;
if let Some(arr_len) = arr_len_const.try_eval_usize(cx.tcx, cx.param_env);
then {
return match limits {
Expand Down Expand Up @@ -1256,7 +1256,7 @@ fn check_for_loop_reverse_range<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, arg: &'tcx
let ty = cx.tables.expr_ty(start);
let (sup, eq) = match (start_idx, end_idx) {
(Constant::Int(start_idx), Constant::Int(end_idx)) => (
match ty.sty {
match ty.kind {
ty::Int(ity) => sext(cx.tcx, start_idx, ity) > sext(cx.tcx, end_idx, ity),
ty::Uint(_) => start_idx > end_idx,
_ => false,
Expand Down Expand Up @@ -1345,7 +1345,7 @@ fn check_for_loop_arg(cx: &LateContext<'_, '_>, pat: &Pat, arg: &Expr, expr: &Ex
let fn_arg_tys = method_type.fn_sig(cx.tcx).inputs();
assert_eq!(fn_arg_tys.skip_binder().len(), 1);
if fn_arg_tys.skip_binder()[0].is_region_ptr() {
match cx.tables.expr_ty(&args[0]).sty {
match cx.tables.expr_ty(&args[0]).kind {
// If the length is greater than 32 no traits are implemented for array and
// therefore we cannot use `&`.
ty::Array(_, size) if size.eval_usize(cx.tcx, cx.param_env) > 32 => {},
Expand Down Expand Up @@ -1497,7 +1497,7 @@ fn check_for_loop_over_map_kv<'a, 'tcx>(
if let PatKind::Tuple(ref pat, _) = pat.node {
if pat.len() == 2 {
let arg_span = arg.span;
let (new_pat_span, kind, ty, mutbl) = match cx.tables.expr_ty(arg).sty {
let (new_pat_span, kind, ty, mutbl) = match cx.tables.expr_ty(arg).kind {
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),
Expand Down Expand Up @@ -1852,7 +1852,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::Ref(_, _, mutbl) = ty.sty {
if let ty::Ref(_, _, mutbl) = ty.kind {
if mutbl == MutMutable {
self.prefer_mutable = true;
}
Expand All @@ -1864,7 +1864,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
let def_id = self.cx.tables.type_dependent_def_id(expr.hir_id).unwrap();
for (ty, expr) in self.cx.tcx.fn_sig(def_id).inputs().skip_binder().iter().zip(args) {
self.prefer_mutable = false;
if let ty::Ref(_, _, mutbl) = ty.sty {
if let ty::Ref(_, _, mutbl) = ty.kind {
if mutbl == MutMutable {
self.prefer_mutable = true;
}
Expand Down Expand Up @@ -1960,7 +1960,7 @@ fn is_ref_iterable_type(cx: &LateContext<'_, '_>, e: &Expr) -> bool {

fn is_iterable_array<'tcx>(ty: Ty<'tcx>, cx: &LateContext<'_, 'tcx>) -> bool {
// IntoIterator is currently only implemented for array sizes <= 32 in rustc
match ty.sty {
match ty.kind {
ty::Array(_, n) => (0..=32).contains(&n.eval_usize(cx.tcx, cx.param_env)),
_ => false,
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/map_clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MapClone {
&& match_trait_method(cx, closure_expr, &paths::CLONE_TRAIT) {

let obj_ty = cx.tables.expr_ty(&obj[0]);
if let ty::Ref(_, ty, _) = obj_ty.sty {
if let ty::Ref(_, ty, _) = obj_ty.kind {
let copy = is_copy(cx, ty);
lint(cx, e.span, args[0].span, copy);
} else {
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/map_unit_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ declare_clippy_lint! {
declare_lint_pass!(MapUnit => [OPTION_MAP_UNIT_FN, RESULT_MAP_UNIT_FN]);

fn is_unit_type(ty: Ty<'_>) -> bool {
match ty.sty {
match ty.kind {
ty::Tuple(slice) => slice.is_empty(),
ty::Never => true,
_ => false,
Expand All @@ -104,7 +104,7 @@ fn is_unit_type(ty: Ty<'_>) -> bool {
fn is_unit_function(cx: &LateContext<'_, '_>, expr: &hir::Expr) -> bool {
let ty = cx.tables.expr_ty(expr);

if let ty::FnDef(id, _) = ty.sty {
if let ty::FnDef(id, _) = ty.kind {
if let Some(fn_type) = cx.tcx.fn_sig(id).no_bound_vars() {
return is_unit_type(fn_type.output());
}
Expand Down
Loading