From 2b4cb8568c3ea4d3a3b37f4dbf94f765108a5449 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Thu, 26 Sep 2019 11:08:35 +0200 Subject: [PATCH] Rustup to rust-lang/rust#64513 --- clippy_lints/src/bytecount.rs | 2 +- clippy_lints/src/consts.rs | 20 +++++----- clippy_lints/src/default_trait_access.rs | 2 +- clippy_lints/src/derive.rs | 6 +-- clippy_lints/src/drop_forget_ref.rs | 2 +- clippy_lints/src/enum_clike.rs | 4 +- clippy_lints/src/eta_reduction.rs | 8 ++-- clippy_lints/src/eval_order_dependence.rs | 4 +- clippy_lints/src/excessive_precision.rs | 2 +- clippy_lints/src/fallible_impl_from.rs | 2 +- clippy_lints/src/format.rs | 2 +- clippy_lints/src/identity_op.rs | 2 +- clippy_lints/src/indexing_slicing.rs | 4 +- clippy_lints/src/len_zero.rs | 2 +- clippy_lints/src/loops.rs | 16 ++++---- clippy_lints/src/map_clone.rs | 2 +- clippy_lints/src/map_unit_fn.rs | 4 +- clippy_lints/src/matches.rs | 12 +++--- clippy_lints/src/methods/mod.rs | 40 +++++++++---------- clippy_lints/src/misc.rs | 2 +- clippy_lints/src/mut_mut.rs | 2 +- clippy_lints/src/mut_reference.rs | 4 +- clippy_lints/src/mutex_atomic.rs | 6 +-- clippy_lints/src/needless_borrow.rs | 6 +-- clippy_lints/src/needless_pass_by_value.rs | 2 +- clippy_lints/src/needless_update.rs | 2 +- clippy_lints/src/new_without_default.rs | 2 +- clippy_lints/src/ptr.rs | 2 +- clippy_lints/src/redundant_clone.rs | 2 +- clippy_lints/src/shadow.rs | 2 +- clippy_lints/src/swap.rs | 4 +- clippy_lints/src/transmute.rs | 10 ++--- .../src/trivially_copy_pass_by_ref.rs | 4 +- clippy_lints/src/types.rs | 40 +++++++++---------- clippy_lints/src/utils/higher.rs | 2 +- clippy_lints/src/utils/mod.rs | 14 +++---- clippy_lints/src/vec.rs | 6 +-- 37 files changed, 124 insertions(+), 124 deletions(-) diff --git a/clippy_lints/src/bytecount.rs b/clippy_lints/src/bytecount.rs index 1e1e4317e34e..845b1e0514f6 100644 --- a/clippy_lints/src/bytecount.rs +++ b/clippy_lints/src/bytecount.rs @@ -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) = diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs index 0e1c1e60178f..401a63698a23 100644 --- a/clippy_lints/src/consts.rs +++ b/clippy_lints/src/consts.rs @@ -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)) @@ -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!(), @@ -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"), }; @@ -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, @@ -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, }; @@ -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); @@ -470,7 +470,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> { pub fn miri_to_const(result: &ty::Const<'_>) -> Option { 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( @@ -480,7 +480,7 @@ pub fn miri_to_const(result: &ty::Const<'_>) -> Option { 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 @@ -488,8 +488,8 @@ pub fn miri_to_const(result: &ty::Const<'_>) -> Option { // 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(), diff --git a/clippy_lints/src/default_trait_access.rs b/clippy_lints/src/default_trait_access.rs index fb7ba64836a5..73c17c702b61 100644 --- a/clippy_lints/src/default_trait_access.rs +++ b/clippy_lints/src/default_trait_access.rs @@ -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, diff --git a/clippy_lints/src/derive.rs b/clippy_lints/src/derive.rs index d50a47f8fc5f..6be04dfa687b 100644 --- a/clippy_lints/src/derive.rs +++ b/clippy_lints/src/derive.rs @@ -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; } } diff --git a/clippy_lints/src/drop_forget_ref.rs b/clippy_lints/src/drop_forget_ref.rs index 023fd5693183..29a35c05ecaa 100644 --- a/clippy_lints/src/drop_forget_ref.rs +++ b/clippy_lints/src/drop_forget_ref.rs @@ -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(); diff --git a/clippy_lints/src/enum_clike.rs b/clippy_lints/src/enum_clike.rs index 079b3bd3f4e5..b74cb9862678 100644 --- a/clippy_lints/src/enum_clike.rs +++ b/clippy_lints/src/enum_clike.rs @@ -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() { diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index 485a29ed3d89..a92ac5865d95 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -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); @@ -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, @@ -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(_)) @@ -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(), diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs index efd4e1e0334c..83da6dd589e0 100644 --- a/clippy_lints/src/eval_order_dependence.rs +++ b/clippy_lints/src/eval_order_dependence.rs @@ -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); } }, diff --git a/clippy_lints/src/excessive_precision.rs b/clippy_lints/src/excessive_precision.rs index 879fb79c0bd3..c95e536d1406 100644 --- a/clippy_lints/src/excessive_precision.rs +++ b/clippy_lints/src/excessive_precision.rs @@ -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); diff --git a/clippy_lints/src/fallible_impl_from.rs b/clippy_lints/src/fallible_impl_from.rs index ed50969506c4..4b6a2eaf796f 100644 --- a/clippy_lints/src/fallible_impl_from.rs +++ b/clippy_lints/src/fallible_impl_from.rs @@ -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, } diff --git a/clippy_lints/src/format.rs b/clippy_lints/src/format.rs index 4f763863ffde..85d360afd816 100644 --- a/clippy_lints/src/format.rs +++ b/clippy_lints/src/format.rs @@ -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 { diff --git a/clippy_lints/src/identity_op.rs b/clippy_lints/src/identity_op.rs index 55f8701ab18b..f4b98fc60cae 100644 --- a/clippy_lints/src/identity_op.rs +++ b/clippy_lints/src/identity_op.rs @@ -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, diff --git a/clippy_lints/src/indexing_slicing.rs b/clippy_lints/src/indexing_slicing.rs index 02dafbe2e398..d9924212e2ec 100644 --- a/clippy_lints/src/indexing_slicing.rs +++ b/clippy_lints/src/indexing_slicing.rs @@ -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); @@ -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. diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index a1c61edbba58..ef924775a18f 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -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 diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 0a315fe48b5d..006f8833afcb 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -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, @@ -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 { @@ -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, @@ -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 => {}, @@ -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), @@ -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; } @@ -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; } @@ -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, } diff --git a/clippy_lints/src/map_clone.rs b/clippy_lints/src/map_clone.rs index 5c44346aa6df..b6264af9dfaa 100644 --- a/clippy_lints/src/map_clone.rs +++ b/clippy_lints/src/map_clone.rs @@ -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 { diff --git a/clippy_lints/src/map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs index a888834551c9..ddbd4e961d99 100644 --- a/clippy_lints/src/map_unit_fn.rs +++ b/clippy_lints/src/map_unit_fn.rs @@ -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, @@ -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()); } diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index ac4f012f35b3..1c5a8f6240c6 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -271,7 +271,7 @@ fn check_single_match(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm], expr: & return; }; let ty = cx.tables.expr_ty(ex); - if ty.sty != ty::Bool || is_allowed(cx, MATCH_BOOL, ex.hir_id) { + if ty.kind != ty::Bool || is_allowed(cx, MATCH_BOOL, ex.hir_id) { check_single_match_single_pattern(cx, ex, arms, expr, els); check_single_match_opt_like(cx, ex, arms, expr, ty, els); } @@ -360,7 +360,7 @@ fn check_single_match_opt_like( fn check_match_bool(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm], expr: &Expr) { // Type of expression is `bool`. - if cx.tables.expr_ty(ex).sty == ty::Bool { + if cx.tables.expr_ty(ex).kind == ty::Bool { span_lint_and_then( cx, MATCH_BOOL, @@ -497,7 +497,7 @@ fn check_wild_enum_match(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm]) { // already covered. let mut missing_variants = vec![]; - if let ty::Adt(def, _) = ty.sty { + if let ty::Adt(def, _) = ty.kind { for variant in &def.variants { missing_variants.push(variant); } @@ -622,11 +622,11 @@ fn check_match_as_ref(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm], expr: & let input_ty = cx.tables.expr_ty(ex); let cast = if_chain! { - if let ty::Adt(_, substs) = input_ty.sty; + if let ty::Adt(_, substs) = input_ty.kind; let input_ty = substs.type_at(0); - if let ty::Adt(_, substs) = output_ty.sty; + if let ty::Adt(_, substs) = output_ty.kind; let output_ty = substs.type_at(0); - if let ty::Ref(_, output_ty, _) = output_ty.sty; + if let ty::Ref(_, output_ty, _) = output_ty.kind; if input_ty != output_ty; then { ".map(|x| x as _)" diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 54c93ca0d4e5..9c0fbc4d56cd 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -1123,8 +1123,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Methods { lint_clone_on_ref_ptr(cx, expr, &args[0]); } - match self_ty.sty { - ty::Ref(_, ty, _) if ty.sty == ty::Str => { + match self_ty.kind { + ty::Ref(_, ty, _) if ty.kind == ty::Str => { for &(method, pos) in &PATTERN_METHODS { if method_call.ident.name.as_str() == method && args.len() > pos { lint_single_char_pattern(cx, expr, &args[pos]); @@ -1230,7 +1230,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Methods { } // if return type is impl trait, check the associated types - if let ty::Opaque(def_id, _) = ret_ty.sty { + if let ty::Opaque(def_id, _) = ret_ty.kind { // one of the associated types must be Self for predicate in &cx.tcx.predicates_of(def_id).predicates { match predicate { @@ -1453,7 +1453,7 @@ fn lint_expect_fun_call(cx: &LateContext<'_, '_>, expr: &hir::Expr, method_span: && { let arg_type = cx.tables.expr_ty(&call_args[0]); let base_type = walk_ptrs_ty(arg_type); - base_type.sty == ty::Str || match_type(cx, base_type, &paths::STRING) + base_type.kind == ty::Str || match_type(cx, base_type, &paths::STRING) } { &call_args[0] @@ -1474,8 +1474,8 @@ fn lint_expect_fun_call(cx: &LateContext<'_, '_>, expr: &hir::Expr, method_span: if match_type(cx, arg_ty, &paths::STRING) { return false; } - if let ty::Ref(ty::ReStatic, ty, ..) = arg_ty.sty { - if ty.sty == ty::Str { + if let ty::Ref(ty::ReStatic, ty, ..) = arg_ty.kind { + if ty.kind == ty::Str { return false; } }; @@ -1583,8 +1583,8 @@ fn lint_expect_fun_call(cx: &LateContext<'_, '_>, expr: &hir::Expr, method_span: /// Checks for the `CLONE_ON_COPY` lint. fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Expr, arg_ty: Ty<'_>) { let ty = cx.tables.expr_ty(expr); - if let ty::Ref(_, inner, _) = arg_ty.sty { - if let ty::Ref(_, innermost, _) = inner.sty { + if let ty::Ref(_, inner, _) = arg_ty.kind { + if let ty::Ref(_, innermost, _) = inner.kind { span_lint_and_then( cx, CLONE_DOUBLE_REF, @@ -1595,7 +1595,7 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp if let Some(snip) = sugg::Sugg::hir_opt(cx, arg) { let mut ty = innermost; let mut n = 0; - while let ty::Ref(_, inner, _) = ty.sty { + while let ty::Ref(_, inner, _) = ty.kind { ty = inner; n += 1; } @@ -1677,7 +1677,7 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp fn lint_clone_on_ref_ptr(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Expr) { let obj_ty = walk_ptrs_ty(cx.tables.expr_ty(arg)); - if let ty::Adt(_, subst) = obj_ty.sty { + if let ty::Adt(_, subst) = obj_ty.kind { let caller_type = if match_type(cx, obj_ty, &paths::RC) { "Rc" } else if match_type(cx, obj_ty, &paths::ARC) { @@ -1710,7 +1710,7 @@ fn lint_string_extend(cx: &LateContext<'_, '_>, expr: &hir::Expr, args: &[hir::E if let Some(arglists) = method_chain_args(arg, &["chars"]) { let target = &arglists[0][0]; let self_ty = walk_ptrs_ty(cx.tables.expr_ty(target)); - let ref_str = if self_ty.sty == ty::Str { + let ref_str = if self_ty.kind == ty::Str { "" } else if match_type(cx, self_ty, &paths::STRING) { "&" @@ -1746,7 +1746,7 @@ fn lint_extend(cx: &LateContext<'_, '_>, expr: &hir::Expr, args: &[hir::Expr]) { fn lint_cstring_as_ptr(cx: &LateContext<'_, '_>, expr: &hir::Expr, source: &hir::Expr, unwrap: &hir::Expr) { if_chain! { let source_type = cx.tables.expr_ty(source); - if let ty::Adt(def, substs) = source_type.sty; + if let ty::Adt(def, substs) = source_type.kind; if match_def_path(cx, def.did, &paths::RESULT); if match_type(cx, substs.type_at(0), &paths::CSTRING); then { @@ -1985,7 +1985,7 @@ fn derefs_to_slice<'a, 'tcx>( ty: Ty<'tcx>, ) -> Option<&'tcx hir::Expr> { fn may_slice<'a>(cx: &LateContext<'_, 'a>, ty: Ty<'a>) -> bool { - match ty.sty { + match ty.kind { ty::Slice(_) => true, ty::Adt(def, _) if def.is_box() => may_slice(cx, ty.boxed_ty()), ty::Adt(..) => is_type_diagnostic_item(cx, ty, Symbol::intern("vec_type")), @@ -2002,7 +2002,7 @@ fn derefs_to_slice<'a, 'tcx>( None } } else { - match ty.sty { + match ty.kind { ty::Slice(_) => Some(expr), ty::Adt(def, _) if def.is_box() && may_slice(cx, ty.boxed_ty()) => Some(expr), ty::Ref(_, inner, _) => { @@ -2525,7 +2525,7 @@ fn lint_chars_cmp( let mut applicability = Applicability::MachineApplicable; let self_ty = walk_ptrs_ty(cx.tables.expr_ty_adjusted(&args[0][0])); - if self_ty.sty != ty::Str { + if self_ty.kind != ty::Str { return false; } @@ -2690,7 +2690,7 @@ fn ty_has_iter_method( } else { INTO_ITER_ON_REF }; - let mutbl = match self_ref_ty.sty { + let mutbl = match self_ref_ty.kind { ty::Ref(_, _, mutbl) => mutbl, _ => unreachable!(), }; @@ -2742,7 +2742,7 @@ fn lint_maybe_uninit(cx: &LateContext<'_, '_>, expr: &hir::Expr, outer: &hir::Ex } fn is_maybe_uninit_ty_valid(cx: &LateContext<'_, '_>, ty: Ty<'_>) -> bool { - match ty.sty { + match ty.kind { ty::Array(ref component, _) => is_maybe_uninit_ty_valid(cx, component), ty::Tuple(ref types) => types.types().all(|ty| is_maybe_uninit_ty_valid(cx, ty)), ty::Adt(ref adt, _) => { @@ -2765,7 +2765,7 @@ fn lint_suspicious_map(cx: &LateContext<'_, '_>, expr: &hir::Expr) { /// Given a `Result` type, return its error type (`E`). fn get_error_type<'a>(cx: &LateContext<'_, '_>, ty: Ty<'a>) -> Option> { - match ty.sty { + match ty.kind { ty::Adt(_, substs) if match_type(cx, ty, &paths::RESULT) => substs.types().nth(1), _ => None, } @@ -2865,7 +2865,7 @@ impl SelfKind { } else if ty.is_box() { ty.boxed_ty() == parent_ty } else if ty.is_rc() || ty.is_arc() { - if let ty::Adt(_, substs) = ty.sty { + if let ty::Adt(_, substs) = ty.kind { substs.types().next().map_or(false, |t| t == parent_ty) } else { false @@ -2881,7 +2881,7 @@ impl SelfKind { parent_ty: Ty<'a>, ty: Ty<'a>, ) -> bool { - if let ty::Ref(_, t, m) = ty.sty { + if let ty::Ref(_, t, m) = ty.kind { return m == mutability && t == parent_ty; } diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 980c4caf2c5e..0cf6b6093c61 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -494,7 +494,7 @@ fn is_signum(cx: &LateContext<'_, '_>, expr: &Expr) -> bool { } fn is_float(cx: &LateContext<'_, '_>, expr: &Expr) -> bool { - matches!(walk_ptrs_ty(cx.tables.expr_ty(expr)).sty, ty::Float(_)) + matches!(walk_ptrs_ty(cx.tables.expr_ty(expr)).kind, ty::Float(_)) } fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) { diff --git a/clippy_lints/src/mut_mut.rs b/clippy_lints/src/mut_mut.rs index decc684b6677..457062d5dd1b 100644 --- a/clippy_lints/src/mut_mut.rs +++ b/clippy_lints/src/mut_mut.rs @@ -65,7 +65,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for MutVisitor<'a, 'tcx> { expr.span, "generally you want to avoid `&mut &mut _` if possible", ); - } else if let ty::Ref(_, _, hir::MutMutable) = self.cx.tables.expr_ty(e).sty { + } else if let ty::Ref(_, _, hir::MutMutable) = self.cx.tables.expr_ty(e).kind { span_lint( self.cx, MUT_MUT, diff --git a/clippy_lints/src/mut_reference.rs b/clippy_lints/src/mut_reference.rs index 9f356e7ca792..e8f3beb9f923 100644 --- a/clippy_lints/src/mut_reference.rs +++ b/clippy_lints/src/mut_reference.rs @@ -50,11 +50,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnecessaryMutPassed { } fn check_arguments<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, arguments: &[Expr], type_definition: Ty<'tcx>, name: &str) { - match type_definition.sty { + match type_definition.kind { ty::FnDef(..) | ty::FnPtr(_) => { let parameters = type_definition.fn_sig(cx.tcx).skip_binder().inputs(); for (argument, parameter) in arguments.iter().zip(parameters.iter()) { - match parameter.sty { + match parameter.kind { ty::Ref(_, _, MutImmutable) | ty::RawPtr(ty::TypeAndMut { mutbl: MutImmutable, .. diff --git a/clippy_lints/src/mutex_atomic.rs b/clippy_lints/src/mutex_atomic.rs index 522c4ab52e2e..d4194b0ca413 100644 --- a/clippy_lints/src/mutex_atomic.rs +++ b/clippy_lints/src/mutex_atomic.rs @@ -57,7 +57,7 @@ declare_lint_pass!(Mutex => [MUTEX_ATOMIC, MUTEX_INTEGER]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Mutex { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { let ty = cx.tables.expr_ty(expr); - if let ty::Adt(_, subst) = ty.sty { + if let ty::Adt(_, subst) = ty.kind { if match_type(cx, ty, &paths::MUTEX) { let mutex_param = subst.type_at(0); if let Some(atomic_name) = get_atomic_name(mutex_param) { @@ -66,7 +66,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Mutex { behaviour and not the internal type, consider using Mutex<()>.", atomic_name ); - match mutex_param.sty { + match mutex_param.kind { ty::Uint(t) if t != ast::UintTy::Usize => span_lint(cx, MUTEX_INTEGER, expr.span, &msg), ty::Int(t) if t != ast::IntTy::Isize => span_lint(cx, MUTEX_INTEGER, expr.span, &msg), _ => span_lint(cx, MUTEX_ATOMIC, expr.span, &msg), @@ -78,7 +78,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Mutex { } fn get_atomic_name(ty: Ty<'_>) -> Option<(&'static str)> { - match ty.sty { + match ty.kind { ty::Bool => Some("AtomicBool"), ty::Uint(_) => Some("AtomicUsize"), ty::Int(_) => Some("AtomicIsize"), diff --git a/clippy_lints/src/needless_borrow.rs b/clippy_lints/src/needless_borrow.rs index 3a0b6d0fbdf0..da363a9b6d67 100644 --- a/clippy_lints/src/needless_borrow.rs +++ b/clippy_lints/src/needless_borrow.rs @@ -42,7 +42,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow { return; } if let ExprKind::AddrOf(MutImmutable, ref inner) = e.node { - if let ty::Ref(..) = cx.tables.expr_ty(inner).sty { + if let ty::Ref(..) = cx.tables.expr_ty(inner).kind { for adj3 in cx.tables.expr_adjustments(e).windows(3) { if let [Adjustment { kind: Adjust::Deref(_), .. @@ -81,9 +81,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow { } if_chain! { if let PatKind::Binding(BindingAnnotation::Ref, .., name, _) = pat.node; - if let ty::Ref(_, tam, mutbl) = cx.tables.pat_ty(pat).sty; + if let ty::Ref(_, tam, mutbl) = cx.tables.pat_ty(pat).kind; if mutbl == MutImmutable; - if let ty::Ref(_, _, mutbl) = tam.sty; + if let ty::Ref(_, _, mutbl) = tam.kind; // only lint immutable refs, because borrowed `&mut T` cannot be moved out if mutbl == MutImmutable; then { diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index 16693d8209bc..66e84a404c54 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -211,7 +211,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { // Dereference suggestion let sugg = |db: &mut DiagnosticBuilder<'_>| { - if let ty::Adt(def, ..) = ty.sty { + if let ty::Adt(def, ..) = ty.kind { if let Some(span) = cx.tcx.hir().span_if_local(def.did) { if cx.param_env.can_type_implement_copy(cx.tcx, ty).is_ok() { db.span_help(span, "consider marking this type as Copy"); diff --git a/clippy_lints/src/needless_update.rs b/clippy_lints/src/needless_update.rs index fdaa14dfb6ae..8cc27182d83c 100644 --- a/clippy_lints/src/needless_update.rs +++ b/clippy_lints/src/needless_update.rs @@ -38,7 +38,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessUpdate { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { if let ExprKind::Struct(_, ref fields, Some(ref base)) = expr.node { let ty = cx.tables.expr_ty(expr); - if let ty::Adt(def, _) = ty.sty { + if let ty::Adt(def, _) = ty.kind { if fields.len() == def.non_enum_variant().fields.len() { span_lint( cx, diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index b2bfb51d6f9d..16c8e2c4c479 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -214,7 +214,7 @@ fn create_new_without_default_suggest_msg(ty: Ty<'_>) -> String { } fn can_derive_default<'t, 'c>(ty: Ty<'t>, cx: &LateContext<'c, 't>, default_trait_id: DefId) -> Option { - match ty.sty { + match ty.kind { ty::Adt(adt_def, substs) if adt_def.is_struct() => { for field in adt_def.all_fields() { let f_ty = field.ty(cx.tcx, substs); diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index d95d61e4027e..f5cc89a73304 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -150,7 +150,7 @@ fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: HirId, opt_body_id: let fn_ty = sig.skip_binder(); for (idx, (arg, ty)) in decl.inputs.iter().zip(fn_ty.inputs()).enumerate() { - if let ty::Ref(_, ty, MutImmutable) = ty.sty { + if let ty::Ref(_, ty, MutImmutable) = ty.kind { if is_type_diagnostic_item(cx, ty, Symbol::intern("vec_type")) { let mut ty_snippet = None; if_chain! { diff --git a/clippy_lints/src/redundant_clone.rs b/clippy_lints/src/redundant_clone.rs index d029267e034d..09a55d264246 100644 --- a/clippy_lints/src/redundant_clone.rs +++ b/clippy_lints/src/redundant_clone.rs @@ -227,7 +227,7 @@ fn is_call_with_ref_arg<'tcx>( if let TerminatorKind::Call { func, args, destination, .. } = kind; if args.len() == 1; if let mir::Operand::Move(mir::Place { base: mir::PlaceBase::Local(local), .. }) = &args[0]; - if let ty::FnDef(def_id, _) = func.ty(&*mir, cx.tcx).sty; + if let ty::FnDef(def_id, _) = func.ty(&*mir, cx.tcx).kind; if let (inner_ty, 1) = walk_ptrs_ty_depth(args[0].ty(&*mir, cx.tcx)); if !is_copy(cx, inner_ty); then { diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index ebef0449cc98..a9467756c111 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -151,7 +151,7 @@ fn check_local<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, local: &'tcx Local, binding fn is_binding(cx: &LateContext<'_, '_>, pat_id: HirId) -> bool { let var_ty = cx.tables.node_type(pat_id); - match var_ty.sty { + match var_ty.kind { ty::Adt(..) => false, _ => true, } diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index cde49db2375b..998d008c6a85 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -107,8 +107,8 @@ fn check_manual_swap(cx: &LateContext<'_, '_>, block: &Block) { if SpanlessEq::new(cx).ignore_fn().eq_expr(lhs1, lhs2) { let ty = walk_ptrs_ty(cx.tables.expr_ty(lhs1)); - if matches!(ty.sty, ty::Slice(_)) || - matches!(ty.sty, ty::Array(_, _)) || + if matches!(ty.kind, ty::Slice(_)) || + matches!(ty.kind, ty::Array(_, _)) || is_type_diagnostic_item(cx, ty, Symbol::intern("vec_type")) || match_type(cx, ty, &paths::VEC_DEQUE) { return Some((lhs1, idx1, idx2)); diff --git a/clippy_lints/src/transmute.rs b/clippy_lints/src/transmute.rs index a514b9c512db..31223cb27a2e 100644 --- a/clippy_lints/src/transmute.rs +++ b/clippy_lints/src/transmute.rs @@ -238,7 +238,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { let from_ty = cx.tables.expr_ty(&args[0]); let to_ty = cx.tables.expr_ty(e); - match (&from_ty.sty, &to_ty.sty) { + match (&from_ty.kind, &to_ty.kind) { _ if from_ty == to_ty => span_lint( cx, USELESS_TRANSMUTE, @@ -349,7 +349,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { &format!("transmute from a `{}` to a `char`", from_ty), |db| { let arg = sugg::Sugg::hir(cx, &args[0], ".."); - let arg = if let ty::Int(_) = from_ty.sty { + let arg = if let ty::Int(_) = from_ty.kind { arg.as_ty(ast::UintTy::U32) } else { arg @@ -365,8 +365,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { }, (&ty::Ref(_, ty_from, from_mutbl), &ty::Ref(_, ty_to, to_mutbl)) => { if_chain! { - if let (&ty::Slice(slice_ty), &ty::Str) = (&ty_from.sty, &ty_to.sty); - if let ty::Uint(ast::UintTy::U8) = slice_ty.sty; + if let (&ty::Slice(slice_ty), &ty::Str) = (&ty_from.kind, &ty_to.kind); + if let ty::Uint(ast::UintTy::U8) = slice_ty.kind; if from_mutbl == to_mutbl; then { let postfix = if from_mutbl == Mutability::MutMutable { @@ -463,7 +463,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { &format!("transmute from a `{}` to a `{}`", from_ty, to_ty), |db| { let arg = sugg::Sugg::hir(cx, &args[0], ".."); - let arg = if let ty::Int(int_ty) = from_ty.sty { + let arg = if let ty::Int(int_ty) = from_ty.kind { arg.as_ty(format!( "u{}", int_ty.bit_width().map_or_else(|| "size".to_string(), |v| v.to_string()) diff --git a/clippy_lints/src/trivially_copy_pass_by_ref.rs b/clippy_lints/src/trivially_copy_pass_by_ref.rs index eb6e46c3014e..3bda90a66e3a 100644 --- a/clippy_lints/src/trivially_copy_pass_by_ref.rs +++ b/clippy_lints/src/trivially_copy_pass_by_ref.rs @@ -82,7 +82,7 @@ impl<'a, 'tcx> TriviallyCopyPassByRef { // Use lifetimes to determine if we're returning a reference to the // argument. In that case we can't switch to pass-by-value as the // argument will not live long enough. - let output_lts = match fn_sig.output().sty { + let output_lts = match fn_sig.output().kind { ty::Ref(output_lt, _, _) => vec![output_lt], ty::Adt(_, substs) => substs.regions().collect(), _ => vec![], @@ -96,7 +96,7 @@ impl<'a, 'tcx> TriviallyCopyPassByRef { } if_chain! { - if let ty::Ref(input_lt, ty, Mutability::MutImmutable) = ty.sty; + if let ty::Ref(input_lt, ty, Mutability::MutImmutable) = ty.kind; if !output_lts.contains(&input_lt); if is_copy(cx, ty); if let Some(size) = cx.layout_of(ty).ok().map(|l| l.size.bytes()); diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index 5696c2be12a8..57be349c1053 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -633,7 +633,7 @@ fn is_questionmark_desugar_marked_call(expr: &Expr) -> bool { } fn is_unit(ty: Ty<'_>) -> bool { - match ty.sty { + match ty.kind { ty::Tuple(slice) if slice.is_empty() => true, _ => false, } @@ -865,7 +865,7 @@ declare_clippy_lint! { /// Returns the size in bits of an integral type. /// Will return 0 if the type is not an int or uint variant fn int_ty_to_nbits(typ: Ty<'_>, tcx: TyCtxt<'_>) -> u64 { - match typ.sty { + match typ.kind { ty::Int(i) => match i { IntTy::Isize => tcx.data_layout.pointer_size.bits(), IntTy::I8 => 8, @@ -887,7 +887,7 @@ fn int_ty_to_nbits(typ: Ty<'_>, tcx: TyCtxt<'_>) -> u64 { } fn is_isize_or_usize(typ: Ty<'_>) -> bool { - match typ.sty { + match typ.kind { ty::Int(IntTy::Isize) | ty::Uint(UintTy::Usize) => true, _ => false, } @@ -979,7 +979,7 @@ fn check_loss_of_sign(cx: &LateContext<'_, '_>, expr: &Expr, op: &Expr, cast_fro if_chain! { if let Some((const_val, _)) = const_val; if let Constant::Int(n) = const_val; - if let ty::Int(ity) = cast_from.sty; + if let ty::Int(ity) = cast_from.kind; if sext(cx.tcx, n, ity) >= 0; then { return @@ -1090,7 +1090,7 @@ declare_lint_pass!(Casts => [ // Check if the given type is either `core::ffi::c_void` or // one of the platform specific `libc::::c_void` of libc. fn is_c_void(cx: &LateContext<'_, '_>, ty: Ty<'_>) -> bool { - if let ty::Adt(adt, _) = ty.sty { + if let ty::Adt(adt, _) = ty.kind { let names = cx.get_def_path(adt.did); if names.is_empty() { @@ -1106,7 +1106,7 @@ fn is_c_void(cx: &LateContext<'_, '_>, ty: Ty<'_>) -> bool { /// Returns the mantissa bits wide of a fp type. /// Will return 0 if the type is not a fp fn fp_ty_mantissa_nbits(typ: Ty<'_>) -> u32 { - match typ.sty { + match typ.kind { ty::Float(FloatTy::F32) => 23, ty::Float(FloatTy::F64) | ty::Infer(InferTy::FloatVar(_)) => 52, _ => 0, @@ -1143,7 +1143,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Casts { match lit.node { LitKind::Int(_, LitIntType::Unsuffixed) | LitKind::FloatUnsuffixed(_) => {}, _ => { - if cast_from.sty == cast_to.sty && !in_external_macro(cx.sess(), expr.span) { + if cast_from.kind == cast_to.kind && !in_external_macro(cx.sess(), expr.span) { span_lint( cx, UNNECESSARY_CAST, @@ -1176,7 +1176,7 @@ fn lint_numeric_casts<'tcx>( match (cast_from.is_integral(), cast_to.is_integral()) { (true, false) => { let from_nbits = int_ty_to_nbits(cast_from, cx.tcx); - let to_nbits = if let ty::Float(FloatTy::F32) = cast_to.sty { + let to_nbits = if let ty::Float(FloatTy::F32) = cast_to.kind { 32 } else { 64 @@ -1210,7 +1210,7 @@ fn lint_numeric_casts<'tcx>( check_lossless(cx, expr, cast_expr, cast_from, cast_to); }, (false, false) => { - if let (&ty::Float(FloatTy::F64), &ty::Float(FloatTy::F32)) = (&cast_from.sty, &cast_to.sty) { + if let (&ty::Float(FloatTy::F64), &ty::Float(FloatTy::F32)) = (&cast_from.kind, &cast_to.kind) { span_lint( cx, CAST_POSSIBLE_TRUNCATION, @@ -1218,7 +1218,7 @@ fn lint_numeric_casts<'tcx>( "casting f64 to f32 may truncate the value", ); } - if let (&ty::Float(FloatTy::F32), &ty::Float(FloatTy::F64)) = (&cast_from.sty, &cast_to.sty) { + if let (&ty::Float(FloatTy::F32), &ty::Float(FloatTy::F64)) = (&cast_from.kind, &cast_to.kind) { span_lossless_lint(cx, expr, cast_expr, cast_from, cast_to); } }, @@ -1227,8 +1227,8 @@ fn lint_numeric_casts<'tcx>( fn lint_cast_ptr_alignment<'tcx>(cx: &LateContext<'_, 'tcx>, expr: &Expr, cast_from: Ty<'tcx>, cast_to: Ty<'tcx>) { if_chain! { - if let ty::RawPtr(from_ptr_ty) = &cast_from.sty; - if let ty::RawPtr(to_ptr_ty) = &cast_to.sty; + if let ty::RawPtr(from_ptr_ty) = &cast_from.kind; + if let ty::RawPtr(to_ptr_ty) = &cast_to.kind; if let Ok(from_layout) = cx.layout_of(from_ptr_ty.ty); if let Ok(to_layout) = cx.layout_of(to_ptr_ty.ty); if from_layout.align.abi < to_layout.align.abi; @@ -1261,11 +1261,11 @@ fn lint_fn_to_numeric_cast( cast_to: Ty<'_>, ) { // We only want to check casts to `ty::Uint` or `ty::Int` - match cast_to.sty { + match cast_to.kind { ty::Uint(_) | ty::Int(..) => { /* continue on */ }, _ => return, } - match cast_from.sty { + match cast_from.kind { ty::FnDef(..) | ty::FnPtr(_) => { let mut applicability = Applicability::MaybeIncorrect; let from_snippet = snippet_with_applicability(cx, cast_expr.span, "x", &mut applicability); @@ -1284,7 +1284,7 @@ fn lint_fn_to_numeric_cast( format!("{} as usize", from_snippet), applicability, ); - } else if cast_to.sty != ty::Uint(UintTy::Usize) { + } else if cast_to.kind != ty::Uint(UintTy::Usize) { span_lint_and_sugg( cx, FN_TO_NUMERIC_CAST, @@ -1498,7 +1498,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CharLitAsU8 { if let ExprKind::Cast(e, _) = &expr.node; if let ExprKind::Lit(l) = &e.node; if let LitKind::Char(c) = l.node; - if ty::Uint(UintTy::U8) == cx.tables.expr_ty(expr).sty; + if ty::Uint(UintTy::U8) == cx.tables.expr_ty(expr).kind; then { let mut applicability = Applicability::MachineApplicable; let snippet = snippet_with_applicability(cx, e.span, "'x'", &mut applicability); @@ -1642,7 +1642,7 @@ fn detect_extreme_expr<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) - let cv = constant(cx, cx.tables, expr)?.0; - let which = match (&ty.sty, cv) { + let which = match (&ty.kind, cv) { (&ty::Bool, Constant::Bool(false)) | (&ty::Uint(_), Constant::Int(0)) => Minimum, (&ty::Int(ity), Constant::Int(i)) if i == unsext(cx.tcx, i128::min_value() >> (128 - int_bits(cx.tcx, ity)), ity) => @@ -1778,7 +1778,7 @@ fn numeric_cast_precast_bounds<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr) -> if cx.layout_of(pre_cast_ty).ok().map(|l| l.size) == cx.layout_of(cast_ty).ok().map(|l| l.size) { return None; } - match pre_cast_ty.sty { + match pre_cast_ty.kind { ty::Int(int_ty) => Some(match int_ty { IntTy::I8 => ( FullInt::S(i128::from(i8::min_value())), @@ -1835,7 +1835,7 @@ fn numeric_cast_precast_bounds<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr) -> fn node_as_const_fullint<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) -> Option { let val = constant(cx, cx.tables, expr)?.0; if let Constant::Int(const_int) = val { - match cx.tables.expr_ty(expr).sty { + match cx.tables.expr_ty(expr).kind { ty::Int(ity) => Some(FullInt::S(sext(cx.tcx, const_int, ity))), ty::Uint(_) => Some(FullInt::U(const_int)), _ => None, @@ -2330,7 +2330,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RefToMut { if let TyKind::Ptr(MutTy { mutbl: Mutability::MutMutable, .. }) = t.node; if let ExprKind::Cast(e, t) = &e.node; if let TyKind::Ptr(MutTy { mutbl: Mutability::MutImmutable, .. }) = t.node; - if let ty::Ref(..) = cx.tables.node_type(e.hir_id).sty; + if let ty::Ref(..) = cx.tables.node_type(e.hir_id).kind; then { span_lint( cx, diff --git a/clippy_lints/src/utils/higher.rs b/clippy_lints/src/utils/higher.rs index 6fb2a3622c60..dd53a7111a2a 100644 --- a/clippy_lints/src/utils/higher.rs +++ b/clippy_lints/src/utils/higher.rs @@ -54,7 +54,7 @@ pub fn range<'a, 'b, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'b hir::Expr) -> O Some(expr) } - let def_path = match cx.tables.expr_ty(expr).sty { + let def_path = match cx.tables.expr_ty(expr).kind { ty::Adt(def, _) => cx.tcx.def_path(def.did), _ => return None, }; diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index ca0927636d74..235c083dbe03 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -125,7 +125,7 @@ pub fn is_present_in_source(cx: &T, span: Span) -> bool { /// Checks if type is struct, enum or union type with the given def path. pub 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, } @@ -133,7 +133,7 @@ pub fn match_type(cx: &LateContext<'_, '_>, ty: Ty<'_>, path: &[&str]) -> bool { /// Checks if the type is equal to a diagnostic item pub fn is_type_diagnostic_item(cx: &LateContext<'_, '_>, ty: Ty<'_>, diag_item: Symbol) -> bool { - match ty.sty { + match ty.kind { ty::Adt(adt, _) => cx.tcx.is_diagnostic_item(diag_item, adt.did), _ => false, } @@ -665,7 +665,7 @@ pub fn walk_ptrs_hir_ty(ty: &hir::Ty) -> &hir::Ty { /// Returns the base type for references and raw pointers. pub fn walk_ptrs_ty(ty: Ty<'_>) -> Ty<'_> { - match ty.sty { + match ty.kind { ty::Ref(_, ty, _) => walk_ptrs_ty(ty), _ => ty, } @@ -675,7 +675,7 @@ pub fn walk_ptrs_ty(ty: Ty<'_>) -> Ty<'_> { /// depth. pub fn walk_ptrs_ty_depth(ty: Ty<'_>) -> (Ty<'_>, usize) { fn inner(ty: Ty<'_>, depth: usize) -> (Ty<'_>, usize) { - match ty.sty { + match ty.kind { ty::Ref(_, ty, _) => inner(ty, depth + 1), _ => (ty, depth), } @@ -792,7 +792,7 @@ pub fn same_tys<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) /// Returns `true` if the given type is an `unsafe` function. pub fn type_is_unsafe_function<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'tcx>) -> bool { - match ty.sty { + match ty.kind { ty::FnDef(..) | ty::FnPtr(_) => ty.fn_sig(cx.tcx).unsafety() == Unsafety::Unsafe, _ => false, } @@ -1063,12 +1063,12 @@ pub fn has_iter_method(cx: &LateContext<'_, '_>, probably_ref_ty: Ty<'_>) -> Opt &paths::RECEIVER, ]; - let ty_to_check = match probably_ref_ty.sty { + let ty_to_check = match probably_ref_ty.kind { ty::Ref(_, ty_to_check, _) => ty_to_check, _ => probably_ref_ty, }; - let def_id = match ty_to_check.sty { + let def_id = match ty_to_check.kind { ty::Array(..) => return Some("array"), ty::Slice(..) => return Some("slice"), ty::Adt(adt, _) => adt.did, diff --git a/clippy_lints/src/vec.rs b/clippy_lints/src/vec.rs index d7709784a3eb..bb97f894c064 100644 --- a/clippy_lints/src/vec.rs +++ b/clippy_lints/src/vec.rs @@ -31,8 +31,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UselessVec { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { // search for `&vec![_]` expressions where the adjusted type is `&[_]` if_chain! { - if let ty::Ref(_, ty, _) = cx.tables.expr_ty_adjusted(expr).sty; - if let ty::Slice(..) = ty.sty; + if let ty::Ref(_, ty, _) = cx.tables.expr_ty_adjusted(expr).kind; + if let ty::Slice(..) = ty.kind; if let ExprKind::AddrOf(_, ref addressee) = expr.node; if let Some(vec_args) = higher::vec_macro(cx, addressee); then { @@ -98,7 +98,7 @@ fn check_vec_macro<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, vec_args: &higher::VecA /// Returns the item type of the vector (i.e., the `T` in `Vec`). fn vec_type(ty: Ty<'_>) -> Ty<'_> { - if let ty::Adt(_, substs) = ty.sty { + if let ty::Adt(_, substs) = ty.kind { substs.type_at(0) } else { panic!("The type of `vec!` is a not a struct?");