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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 10 additions & 10 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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);

0 commit comments

Comments
 (0)