Skip to content

Commit 3335209

Browse files
committed
Auto merge of #4580 - lzutao:rustup, r=flip1995
Rustup rust-lang/rust#64513 changelog: none
2 parents adc1df1 + 5437192 commit 3335209

38 files changed

+124
-125
lines changed

clippy_lints/src/bytecount.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ByteCount {
6262
_ => { return; }
6363
}
6464
};
65-
if ty::Uint(UintTy::U8) != walk_ptrs_ty(cx.tables.expr_ty(needle)).sty {
65+
if ty::Uint(UintTy::U8) != walk_ptrs_ty(cx.tables.expr_ty(needle)).kind {
6666
return;
6767
}
6868
let haystack = if let ExprKind::MethodCall(ref path, _, ref args) =

clippy_lints/src/consts.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl Constant {
124124
(&Self::Str(ref ls), &Self::Str(ref rs)) => Some(ls.cmp(rs)),
125125
(&Self::Char(ref l), &Self::Char(ref r)) => Some(l.cmp(r)),
126126
(&Self::Int(l), &Self::Int(r)) => {
127-
if let ty::Int(int_ty) = cmp_type.sty {
127+
if let ty::Int(int_ty) = cmp_type.kind {
128128
Some(sext(tcx, l, int_ty).cmp(&sext(tcx, r, int_ty)))
129129
} else {
130130
Some(l.cmp(&r))
@@ -161,7 +161,7 @@ pub fn lit_to_constant(lit: &LitKind, ty: Ty<'_>) -> Constant {
161161
LitKind::ByteStr(ref s) => Constant::Binary(Lrc::clone(s)),
162162
LitKind::Char(c) => Constant::Char(c),
163163
LitKind::Int(n, _) => Constant::Int(n),
164-
LitKind::Float(ref is, _) | LitKind::FloatUnsuffixed(ref is) => match ty.sty {
164+
LitKind::Float(ref is, _) | LitKind::FloatUnsuffixed(ref is) => match ty.kind {
165165
ty::Float(FloatTy::F32) => Constant::F32(is.as_str().parse().unwrap()),
166166
ty::Float(FloatTy::F64) => Constant::F64(is.as_str().parse().unwrap()),
167167
_ => bug!(),
@@ -229,7 +229,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
229229
ExprKind::Array(ref vec) => self.multi(vec).map(Constant::Vec),
230230
ExprKind::Tup(ref tup) => self.multi(tup).map(Constant::Tuple),
231231
ExprKind::Repeat(ref value, _) => {
232-
let n = match self.tables.expr_ty(e).sty {
232+
let n = match self.tables.expr_ty(e).kind {
233233
ty::Array(_, n) => n.eval_usize(self.lcx.tcx, self.lcx.param_env),
234234
_ => span_bug!(e.span, "typeck error"),
235235
};
@@ -286,7 +286,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
286286
Bool(b) => Some(Bool(!b)),
287287
Int(value) => {
288288
let value = !value;
289-
match ty.sty {
289+
match ty.kind {
290290
ty::Int(ity) => Some(Int(unsext(self.lcx.tcx, value as i128, ity))),
291291
ty::Uint(ity) => Some(Int(clip(self.lcx.tcx, value, ity))),
292292
_ => None,
@@ -300,7 +300,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
300300
use self::Constant::*;
301301
match *o {
302302
Int(value) => {
303-
let ity = match ty.sty {
303+
let ity = match ty.kind {
304304
ty::Int(ity) => ity,
305305
_ => return None,
306306
};
@@ -378,7 +378,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
378378
let l = self.expr(left)?;
379379
let r = self.expr(right);
380380
match (l, r) {
381-
(Constant::Int(l), Some(Constant::Int(r))) => match self.tables.expr_ty(left).sty {
381+
(Constant::Int(l), Some(Constant::Int(r))) => match self.tables.expr_ty(left).kind {
382382
ty::Int(ity) => {
383383
let l = sext(self.lcx.tcx, l, ity);
384384
let r = sext(self.lcx.tcx, r, ity);
@@ -470,7 +470,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
470470
pub fn miri_to_const(result: &ty::Const<'_>) -> Option<Constant> {
471471
use rustc::mir::interpret::{ConstValue, Scalar};
472472
match result.val {
473-
ConstValue::Scalar(Scalar::Raw { data: d, .. }) => match result.ty.sty {
473+
ConstValue::Scalar(Scalar::Raw { data: d, .. }) => match result.ty.kind {
474474
ty::Bool => Some(Constant::Bool(d == 1)),
475475
ty::Uint(_) | ty::Int(_) => Some(Constant::Int(d)),
476476
ty::Float(FloatTy::F32) => Some(Constant::F32(f32::from_bits(
@@ -480,16 +480,16 @@ pub fn miri_to_const(result: &ty::Const<'_>) -> Option<Constant> {
480480
d.try_into().expect("invalid f64 bit representation"),
481481
))),
482482
ty::RawPtr(type_and_mut) => {
483-
if let ty::Uint(_) = type_and_mut.ty.sty {
483+
if let ty::Uint(_) = type_and_mut.ty.kind {
484484
return Some(Constant::RawPtr(d));
485485
}
486486
None
487487
},
488488
// FIXME: implement other conversions.
489489
_ => None,
490490
},
491-
ConstValue::Slice { data, start, end } => match result.ty.sty {
492-
ty::Ref(_, tam, _) => match tam.sty {
491+
ConstValue::Slice { data, start, end } => match result.ty.kind {
492+
ty::Ref(_, tam, _) => match tam.kind {
493493
ty::Str => String::from_utf8(
494494
data.inspect_with_undef_and_ptr_outside_interpreter(start..end)
495495
.to_owned(),

clippy_lints/src/copies.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
55
use rustc::ty::Ty;
66
use rustc::{declare_lint_pass, declare_tool_lint};
77
use rustc_data_structures::fx::FxHashMap;
8-
use std::cmp::Ordering;
98
use std::collections::hash_map::Entry;
109
use std::hash::BuildHasherDefault;
1110
use syntax::symbol::Symbol;

clippy_lints/src/default_trait_access.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DefaultTraitAccess {
5555
// TODO: Work out a way to put "whatever the imported way of referencing
5656
// this type in this file" rather than a fully-qualified type.
5757
let expr_ty = cx.tables.expr_ty(expr);
58-
if let ty::Adt(..) = expr_ty.sty {
58+
if let ty::Adt(..) = expr_ty.kind {
5959
let replacement = format!("{}::default()", expr_ty);
6060
span_lint_and_sugg(
6161
cx,

clippy_lints/src/derive.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -134,20 +134,20 @@ fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item, trait_ref
134134
return;
135135
}
136136

137-
match ty.sty {
137+
match ty.kind {
138138
ty::Adt(def, _) if def.is_union() => return,
139139

140140
// Some types are not Clone by default but could be cloned “by hand” if necessary
141141
ty::Adt(def, substs) => {
142142
for variant in &def.variants {
143143
for field in &variant.fields {
144-
if let ty::FnDef(..) = field.ty(cx.tcx, substs).sty {
144+
if let ty::FnDef(..) = field.ty(cx.tcx, substs).kind {
145145
return;
146146
}
147147
}
148148
for subst in substs {
149149
if let ty::subst::UnpackedKind::Type(subst) = subst.unpack() {
150-
if let ty::Param(_) = subst.sty {
150+
if let ty::Param(_) = subst.kind {
151151
return;
152152
}
153153
}

clippy_lints/src/drop_forget_ref.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DropForgetRef {
121121
let arg = &args[0];
122122
let arg_ty = cx.tables.expr_ty(arg);
123123

124-
if let ty::Ref(..) = arg_ty.sty {
124+
if let ty::Ref(..) = arg_ty.kind {
125125
if match_def_path(cx, def_id, &paths::DROP) {
126126
lint = DROP_REF;
127127
msg = DROP_REF_SUMMARY.to_string();

clippy_lints/src/enum_clike.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
5757
let constant = cx.tcx.const_eval(param_env.and(c_id)).ok();
5858
if let Some(Constant::Int(val)) = constant.and_then(miri_to_const) {
5959
let mut ty = cx.tcx.type_of(def_id);
60-
if let ty::Adt(adt, _) = ty.sty {
60+
if let ty::Adt(adt, _) = ty.kind {
6161
if adt.is_enum() {
6262
ty = adt.repr.discr_type().to_ty(cx.tcx);
6363
}
6464
}
65-
match ty.sty {
65+
match ty.kind {
6666
ty::Int(IntTy::Isize) => {
6767
let val = ((val as i128) << 64) >> 64;
6868
if i32::try_from(val).is_ok() {

clippy_lints/src/eta_reduction.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ fn check_closure(cx: &LateContext<'_, '_>, expr: &Expr) {
9494

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

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

9999
if !type_is_unsafe_function(cx, fn_ty);
100100

@@ -171,7 +171,7 @@ fn get_ufcs_type_name(
171171
}
172172

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

183183
fn match_types(lhs: Ty<'_>, rhs: Ty<'_>) -> bool {
184-
match (&lhs.sty, &rhs.sty) {
184+
match (&lhs.kind, &rhs.kind) {
185185
(ty::Bool, ty::Bool)
186186
| (ty::Char, ty::Char)
187187
| (ty::Int(_), ty::Int(_))
@@ -195,7 +195,7 @@ fn match_types(lhs: Ty<'_>, rhs: Ty<'_>) -> bool {
195195
}
196196

197197
fn get_type_name(cx: &LateContext<'_, '_>, ty: Ty<'_>) -> String {
198-
match ty.sty {
198+
match ty.kind {
199199
ty::Adt(t, _) => cx.tcx.def_path_str(t.did),
200200
ty::Ref(_, r, _) => get_type_name(cx, &r),
201201
_ => ty.to_string(),

clippy_lints/src/eval_order_dependence.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
128128
ExprKind::Continue(_) | ExprKind::Break(_, _) | ExprKind::Ret(_) => self.report_diverging_sub_expr(e),
129129
ExprKind::Call(ref func, _) => {
130130
let typ = self.cx.tables.expr_ty(func);
131-
match typ.sty {
131+
match typ.kind {
132132
ty::FnDef(..) | ty::FnPtr(_) => {
133133
let sig = typ.fn_sig(self.cx.tcx);
134-
if let ty::Never = self.cx.tcx.erase_late_bound_regions(&sig).output().sty {
134+
if let ty::Never = self.cx.tcx.erase_late_bound_regions(&sig).output().kind {
135135
self.report_diverging_sub_expr(e);
136136
}
137137
},

clippy_lints/src/excessive_precision.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExcessivePrecision {
4141
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
4242
if_chain! {
4343
let ty = cx.tables.expr_ty(expr);
44-
if let ty::Float(fty) = ty.sty;
44+
if let ty::Float(fty) = ty.kind;
4545
if let hir::ExprKind::Lit(ref lit) = expr.node;
4646
if let LitKind::Float(sym, _) | LitKind::FloatUnsuffixed(sym) = lit.node;
4747
if let Some(sugg) = self.check(sym, fty);

clippy_lints/src/fallible_impl_from.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_it
123123
}
124124

125125
fn match_type(cx: &LateContext<'_, '_>, ty: Ty<'_>, path: &[&str]) -> bool {
126-
match ty.sty {
126+
match ty.kind {
127127
ty::Adt(adt, _) => match_def_path(cx, adt.did, path),
128128
_ => false,
129129
}

clippy_lints/src/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ fn on_argumentv1_new<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, arm
8989
if pats.len() == 1;
9090
then {
9191
let ty = walk_ptrs_ty(cx.tables.pat_ty(&pats[0]));
92-
if ty.sty != rustc::ty::Str && !match_type(cx, ty, &paths::STRING) {
92+
if ty.kind != rustc::ty::Str && !match_type(cx, ty, &paths::STRING) {
9393
return None;
9494
}
9595
if let ExprKind::Lit(ref lit) = format_args.node {

clippy_lints/src/identity_op.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityOp {
5757
#[allow(clippy::cast_possible_wrap)]
5858
fn check(cx: &LateContext<'_, '_>, e: &Expr, m: i8, span: Span, arg: Span) {
5959
if let Some(Constant::Int(v)) = constant_simple(cx, cx.tables, e) {
60-
let check = match cx.tables.expr_ty(e).sty {
60+
let check = match cx.tables.expr_ty(e).kind {
6161
ty::Int(ity) => unsext(cx.tcx, -1_i128, ity),
6262
ty::Uint(uty) => clip(cx.tcx, !0, uty),
6363
_ => return,

clippy_lints/src/indexing_slicing.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing {
9393
let ty = cx.tables.expr_ty(array);
9494
if let Some(range) = higher::range(cx, index) {
9595
// Ranged indexes, i.e., &x[n..m], &x[n..], &x[..n] and &x[..]
96-
if let ty::Array(_, s) = ty.sty {
96+
if let ty::Array(_, s) = ty.kind {
9797
let size: u128 = s.eval_usize(cx.tcx, cx.param_env).into();
9898

9999
let const_range = to_const_range(cx, range, size);
@@ -139,7 +139,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing {
139139
utils::span_help_and_lint(cx, INDEXING_SLICING, expr.span, "slicing may panic.", help_msg);
140140
} else {
141141
// Catchall non-range index, i.e., [n] or [n << m]
142-
if let ty::Array(..) = ty.sty {
142+
if let ty::Array(..) = ty.kind {
143143
// Index is a constant uint.
144144
if let Some(..) = constant(cx, cx.tables, index) {
145145
// Let rustc's `const_err` lint handle constant `usize` indexing on arrays.

clippy_lints/src/len_zero.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ fn has_is_empty(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {
280280
}
281281

282282
let ty = &walk_ptrs_ty(cx.tables.expr_ty(expr));
283-
match ty.sty {
283+
match ty.kind {
284284
ty::Dynamic(ref tt, ..) => {
285285
if let Some(principal) = tt.principal() {
286286
cx.tcx

clippy_lints/src/loops.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ struct FixedOffsetVar {
787787
}
788788

789789
fn is_slice_like<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'_>) -> bool {
790-
let is_slice = match ty.sty {
790+
let is_slice = match ty.kind {
791791
ty::Ref(_, subty, _) => is_slice_like(cx, subty),
792792
ty::Slice(..) | ty::Array(..) => true,
793793
_ => false,
@@ -1225,7 +1225,7 @@ fn is_end_eq_array_len<'tcx>(
12251225
if_chain! {
12261226
if let ExprKind::Lit(ref lit) = end.node;
12271227
if let ast::LitKind::Int(end_int, _) = lit.node;
1228-
if let ty::Array(_, arr_len_const) = indexed_ty.sty;
1228+
if let ty::Array(_, arr_len_const) = indexed_ty.kind;
12291229
if let Some(arr_len) = arr_len_const.try_eval_usize(cx.tcx, cx.param_env);
12301230
then {
12311231
return match limits {
@@ -1256,7 +1256,7 @@ fn check_for_loop_reverse_range<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, arg: &'tcx
12561256
let ty = cx.tables.expr_ty(start);
12571257
let (sup, eq) = match (start_idx, end_idx) {
12581258
(Constant::Int(start_idx), Constant::Int(end_idx)) => (
1259-
match ty.sty {
1259+
match ty.kind {
12601260
ty::Int(ity) => sext(cx.tcx, start_idx, ity) > sext(cx.tcx, end_idx, ity),
12611261
ty::Uint(_) => start_idx > end_idx,
12621262
_ => false,
@@ -1345,7 +1345,7 @@ fn check_for_loop_arg(cx: &LateContext<'_, '_>, pat: &Pat, arg: &Expr, expr: &Ex
13451345
let fn_arg_tys = method_type.fn_sig(cx.tcx).inputs();
13461346
assert_eq!(fn_arg_tys.skip_binder().len(), 1);
13471347
if fn_arg_tys.skip_binder()[0].is_region_ptr() {
1348-
match cx.tables.expr_ty(&args[0]).sty {
1348+
match cx.tables.expr_ty(&args[0]).kind {
13491349
// If the length is greater than 32 no traits are implemented for array and
13501350
// therefore we cannot use `&`.
13511351
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>(
14971497
if let PatKind::Tuple(ref pat, _) = pat.node {
14981498
if pat.len() == 2 {
14991499
let arg_span = arg.span;
1500-
let (new_pat_span, kind, ty, mutbl) = match cx.tables.expr_ty(arg).sty {
1500+
let (new_pat_span, kind, ty, mutbl) = match cx.tables.expr_ty(arg).kind {
15011501
ty::Ref(_, ty, mutbl) => match (&pat[0].node, &pat[1].node) {
15021502
(key, _) if pat_is_wild(key, body) => (pat[1].span, "value", ty, mutbl),
15031503
(_, 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> {
18521852
for expr in args {
18531853
let ty = self.cx.tables.expr_ty_adjusted(expr);
18541854
self.prefer_mutable = false;
1855-
if let ty::Ref(_, _, mutbl) = ty.sty {
1855+
if let ty::Ref(_, _, mutbl) = ty.kind {
18561856
if mutbl == MutMutable {
18571857
self.prefer_mutable = true;
18581858
}
@@ -1864,7 +1864,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
18641864
let def_id = self.cx.tables.type_dependent_def_id(expr.hir_id).unwrap();
18651865
for (ty, expr) in self.cx.tcx.fn_sig(def_id).inputs().skip_binder().iter().zip(args) {
18661866
self.prefer_mutable = false;
1867-
if let ty::Ref(_, _, mutbl) = ty.sty {
1867+
if let ty::Ref(_, _, mutbl) = ty.kind {
18681868
if mutbl == MutMutable {
18691869
self.prefer_mutable = true;
18701870
}
@@ -1960,7 +1960,7 @@ fn is_ref_iterable_type(cx: &LateContext<'_, '_>, e: &Expr) -> bool {
19601960

19611961
fn is_iterable_array<'tcx>(ty: Ty<'tcx>, cx: &LateContext<'_, 'tcx>) -> bool {
19621962
// IntoIterator is currently only implemented for array sizes <= 32 in rustc
1963-
match ty.sty {
1963+
match ty.kind {
19641964
ty::Array(_, n) => (0..=32).contains(&n.eval_usize(cx.tcx, cx.param_env)),
19651965
_ => false,
19661966
}

clippy_lints/src/map_clone.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MapClone {
7777
&& match_trait_method(cx, closure_expr, &paths::CLONE_TRAIT) {
7878

7979
let obj_ty = cx.tables.expr_ty(&obj[0]);
80-
if let ty::Ref(_, ty, _) = obj_ty.sty {
80+
if let ty::Ref(_, ty, _) = obj_ty.kind {
8181
let copy = is_copy(cx, ty);
8282
lint(cx, e.span, args[0].span, copy);
8383
} else {

clippy_lints/src/map_unit_fn.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ declare_clippy_lint! {
9494
declare_lint_pass!(MapUnit => [OPTION_MAP_UNIT_FN, RESULT_MAP_UNIT_FN]);
9595

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

107-
if let ty::FnDef(id, _) = ty.sty {
107+
if let ty::FnDef(id, _) = ty.kind {
108108
if let Some(fn_type) = cx.tcx.fn_sig(id).no_bound_vars() {
109109
return is_unit_type(fn_type.output());
110110
}

0 commit comments

Comments
 (0)