Skip to content

Commit 085e417

Browse files
ty.kind -> ty.kind() in rustdoc and clippy
1 parent 3e14b68 commit 085e417

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+204
-203
lines changed

src/librustdoc/clean/blanket_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
3838
);
3939
let trait_ref = self.cx.tcx.impl_trait_ref(impl_def_id).unwrap();
4040
let may_apply = self.cx.tcx.infer_ctxt().enter(|infcx| {
41-
match trait_ref.self_ty().kind {
41+
match trait_ref.self_ty().kind() {
4242
ty::Param(_) => {}
4343
_ => return false,
4444
}

src/librustdoc/clean/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -764,17 +764,17 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx
764764
let param_idx = (|| {
765765
match p.skip_binders() {
766766
ty::PredicateAtom::Trait(pred, _constness) => {
767-
if let ty::Param(param) = pred.self_ty().kind {
767+
if let ty::Param(param) = pred.self_ty().kind() {
768768
return Some(param.index);
769769
}
770770
}
771771
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(ty, _reg)) => {
772-
if let ty::Param(param) = ty.kind {
772+
if let ty::Param(param) = ty.kind() {
773773
return Some(param.index);
774774
}
775775
}
776776
ty::PredicateAtom::Projection(p) => {
777-
if let ty::Param(param) = p.projection_ty.self_ty().kind {
777+
if let ty::Param(param) = p.projection_ty.self_ty().kind() {
778778
projection = Some(ty::Binder::bind(p));
779779
return Some(param.index);
780780
}
@@ -1206,7 +1206,7 @@ impl Clean<Item> for ty::AssocItem {
12061206
let self_arg_ty = sig.input(0).skip_binder();
12071207
if self_arg_ty == self_ty {
12081208
decl.inputs.values[0].type_ = Generic(String::from("Self"));
1209-
} else if let ty::Ref(_, ty, _) = self_arg_ty.kind {
1209+
} else if let ty::Ref(_, ty, _) = *self_arg_ty.kind() {
12101210
if ty == self_ty {
12111211
match decl.inputs.values[0].type_ {
12121212
BorrowedRef { ref mut type_, .. } => {
@@ -1511,7 +1511,7 @@ impl Clean<Type> for hir::Ty<'_> {
15111511
TyKind::Path(hir::QPath::TypeRelative(ref qself, ref segment)) => {
15121512
let mut res = Res::Err;
15131513
let ty = hir_ty_to_ty(cx.tcx, self);
1514-
if let ty::Projection(proj) = ty.kind {
1514+
if let ty::Projection(proj) = ty.kind() {
15151515
res = Res::Def(DefKind::Trait, proj.trait_ref(cx.tcx).def_id);
15161516
}
15171517
let trait_path = hir::Path { span: self.span, res, segments: &[] };
@@ -1554,7 +1554,7 @@ impl Clean<Type> for hir::Ty<'_> {
15541554
impl<'tcx> Clean<Type> for Ty<'tcx> {
15551555
fn clean(&self, cx: &DocContext<'_>) -> Type {
15561556
debug!("cleaning type: {:?}", self);
1557-
match self.kind {
1557+
match *self.kind() {
15581558
ty::Never => Never,
15591559
ty::Bool => Primitive(PrimitiveType::Bool),
15601560
ty::Char => Primitive(PrimitiveType::Char),

src/librustdoc/clean/utils.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub fn external_generic_args(
130130
None
131131
}
132132
GenericArgKind::Type(ty) => {
133-
ty_kind = Some(&ty.kind);
133+
ty_kind = Some(ty.kind());
134134
Some(GenericArg::Type(ty.clean(cx)))
135135
}
136136
GenericArgKind::Const(ct) => Some(GenericArg::Const(ct.clean(cx))),
@@ -472,7 +472,7 @@ pub fn print_const(cx: &DocContext<'_>, n: &'tcx ty::Const<'_>) -> String {
472472
pub fn print_evaluated_const(cx: &DocContext<'_>, def_id: DefId) -> Option<String> {
473473
cx.tcx.const_eval_poly(def_id).ok().and_then(|val| {
474474
let ty = cx.tcx.type_of(def_id);
475-
match (val, &ty.kind) {
475+
match (val, ty.kind()) {
476476
(_, &ty::Ref(..)) => None,
477477
(ConstValue::Scalar(_), &ty::Adt(_, _)) => None,
478478
(ConstValue::Scalar(_), _) => {
@@ -497,7 +497,7 @@ fn format_integer_with_underscore_sep(num: &str) -> String {
497497
fn print_const_with_custom_print_scalar(cx: &DocContext<'_>, ct: &'tcx ty::Const<'tcx>) -> String {
498498
// Use a slightly different format for integer types which always shows the actual value.
499499
// For all other types, fallback to the original `pretty_print_const`.
500-
match (ct.val, &ct.ty.kind) {
500+
match (ct.val, ct.ty.kind()) {
501501
(ty::ConstKind::Value(ConstValue::Scalar(Scalar::Raw { data, .. })), ty::Uint(ui)) => {
502502
format!("{}{}", format_integer_with_underscore_sep(&data.to_string()), ui.name_str())
503503
}

src/librustdoc/passes/collect_intra_doc_links.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
120120
{
121121
return Err(ErrorKind::ResolutionFailure);
122122
}
123-
match cx.tcx.type_of(did).kind {
123+
match cx.tcx.type_of(did).kind() {
124124
ty::Adt(def, _) if def.is_enum() => {
125125
if def.all_fields().any(|item| item.ident.name == variant_field_name) {
126126
Ok((
@@ -343,7 +343,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
343343
Ok((ty_res, Some(format!("{}.{}", out, item_name))))
344344
})
345345
} else if ns == Namespace::ValueNS {
346-
match cx.tcx.type_of(did).kind {
346+
match cx.tcx.type_of(did).kind() {
347347
ty::Adt(def, _) => {
348348
let field = if def.is_enum() {
349349
def.all_fields().find(|item| item.ident.name == item_name)
@@ -538,17 +538,19 @@ fn traits_implemented_by(cx: &DocContext<'_>, type_: DefId, module: DefId) -> Fx
538538
let impl_type = trait_ref.self_ty();
539539
debug!(
540540
"comparing type {} with kind {:?} against type {:?}",
541-
impl_type, impl_type.kind, type_
541+
impl_type,
542+
impl_type.kind(),
543+
type_
542544
);
543545
// Fast path: if this is a primitive simple `==` will work
544546
saw_impl = impl_type == ty
545-
|| match impl_type.kind {
547+
|| match impl_type.kind() {
546548
// Check if these are the same def_id
547549
ty::Adt(def, _) => {
548550
debug!("adt def_id: {:?}", def.did);
549551
def.did == type_
550552
}
551-
ty::Foreign(def_id) => def_id == type_,
553+
ty::Foreign(def_id) => *def_id == type_,
552554
_ => false,
553555
};
554556
});

src/tools/clippy/clippy_lints/src/atomic_ordering.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const ATOMIC_TYPES: [&str; 12] = [
5353
];
5454

5555
fn type_is_atomic(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
56-
if let ty::Adt(&ty::AdtDef { did, .. }, _) = cx.typeck_results().expr_ty(expr).kind {
56+
if let ty::Adt(&ty::AdtDef { did, .. }, _) = cx.typeck_results().expr_ty(expr).kind() {
5757
ATOMIC_TYPES
5858
.iter()
5959
.any(|ty| match_def_path(cx, did, &["core", "sync", "atomic", ty]))

src/tools/clippy/clippy_lints/src/await_holding_lock.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl LateLintPass<'_> for AwaitHoldingLock {
6767

6868
fn check_interior_types(cx: &LateContext<'_>, ty_causes: &[GeneratorInteriorTypeCause<'_>], span: Span) {
6969
for ty_cause in ty_causes {
70-
if let rustc_middle::ty::Adt(adt, _) = ty_cause.ty.kind {
70+
if let rustc_middle::ty::Adt(adt, _) = ty_cause.ty.kind() {
7171
if is_mutex_guard(cx, adt.did) {
7272
span_lint_and_note(
7373
cx,

src/tools/clippy/clippy_lints/src/bytecount.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl<'tcx> LateLintPass<'tcx> for ByteCount {
6363
_ => { return; }
6464
}
6565
};
66-
if ty::Uint(UintTy::U8) != walk_ptrs_ty(cx.typeck_results().expr_ty(needle)).kind {
66+
if ty::Uint(UintTy::U8) != *walk_ptrs_ty(cx.typeck_results().expr_ty(needle)).kind() {
6767
return;
6868
}
6969
let haystack = if let ExprKind::MethodCall(ref path, _, ref args, _) =

src/tools/clippy/clippy_lints/src/consts.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl Constant {
123123
(&Self::Str(ref ls), &Self::Str(ref rs)) => Some(ls.cmp(rs)),
124124
(&Self::Char(ref l), &Self::Char(ref r)) => Some(l.cmp(r)),
125125
(&Self::Int(l), &Self::Int(r)) => {
126-
if let ty::Int(int_ty) = cmp_type.kind {
126+
if let ty::Int(int_ty) = *cmp_type.kind() {
127127
Some(sext(tcx, l, int_ty).cmp(&sext(tcx, r, int_ty)))
128128
} else {
129129
Some(l.cmp(&r))
@@ -162,7 +162,7 @@ pub fn lit_to_constant(lit: &LitKind, ty: Option<Ty<'_>>) -> Constant {
162162
FloatTy::F32 => Constant::F32(is.as_str().parse().unwrap()),
163163
FloatTy::F64 => Constant::F64(is.as_str().parse().unwrap()),
164164
},
165-
LitKind::Float(ref is, LitFloatType::Unsuffixed) => match ty.expect("type of float is known").kind {
165+
LitKind::Float(ref is, LitFloatType::Unsuffixed) => match ty.expect("type of float is known").kind() {
166166
ty::Float(FloatTy::F32) => Constant::F32(is.as_str().parse().unwrap()),
167167
ty::Float(FloatTy::F64) => Constant::F64(is.as_str().parse().unwrap()),
168168
_ => bug!(),
@@ -230,7 +230,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
230230
ExprKind::Array(ref vec) => self.multi(vec).map(Constant::Vec),
231231
ExprKind::Tup(ref tup) => self.multi(tup).map(Constant::Tuple),
232232
ExprKind::Repeat(ref value, _) => {
233-
let n = match self.typeck_results.expr_ty(e).kind {
233+
let n = match self.typeck_results.expr_ty(e).kind() {
234234
ty::Array(_, n) => n.try_eval_usize(self.lcx.tcx, self.lcx.param_env)?,
235235
_ => span_bug!(e.span, "typeck error"),
236236
};
@@ -281,7 +281,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
281281
Bool(b) => Some(Bool(!b)),
282282
Int(value) => {
283283
let value = !value;
284-
match ty.kind {
284+
match *ty.kind() {
285285
ty::Int(ity) => Some(Int(unsext(self.lcx.tcx, value as i128, ity))),
286286
ty::Uint(ity) => Some(Int(clip(self.lcx.tcx, value, ity))),
287287
_ => None,
@@ -295,7 +295,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
295295
use self::Constant::{Int, F32, F64};
296296
match *o {
297297
Int(value) => {
298-
let ity = match ty.kind {
298+
let ity = match *ty.kind() {
299299
ty::Int(ity) => ity,
300300
_ => return None,
301301
};
@@ -402,7 +402,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
402402
let l = self.expr(left)?;
403403
let r = self.expr(right);
404404
match (l, r) {
405-
(Constant::Int(l), Some(Constant::Int(r))) => match self.typeck_results.expr_ty_opt(left)?.kind {
405+
(Constant::Int(l), Some(Constant::Int(r))) => match *self.typeck_results.expr_ty_opt(left)?.kind() {
406406
ty::Int(ity) => {
407407
let l = sext(self.lcx.tcx, l, ity);
408408
let r = sext(self.lcx.tcx, r, ity);
@@ -495,7 +495,7 @@ pub fn miri_to_const(result: &ty::Const<'_>) -> Option<Constant> {
495495
use rustc_middle::mir::interpret::{ConstValue, Scalar};
496496
match result.val {
497497
ty::ConstKind::Value(ConstValue::Scalar(Scalar::Raw { data: d, .. })) => {
498-
match result.ty.kind {
498+
match result.ty.kind() {
499499
ty::Bool => Some(Constant::Bool(d == 1)),
500500
ty::Uint(_) | ty::Int(_) => Some(Constant::Int(d)),
501501
ty::Float(FloatTy::F32) => Some(Constant::F32(f32::from_bits(
@@ -505,7 +505,7 @@ pub fn miri_to_const(result: &ty::Const<'_>) -> Option<Constant> {
505505
d.try_into().expect("invalid f64 bit representation"),
506506
))),
507507
ty::RawPtr(type_and_mut) => {
508-
if let ty::Uint(_) = type_and_mut.ty.kind {
508+
if let ty::Uint(_) = type_and_mut.ty.kind() {
509509
return Some(Constant::RawPtr(d));
510510
}
511511
None
@@ -514,8 +514,8 @@ pub fn miri_to_const(result: &ty::Const<'_>) -> Option<Constant> {
514514
_ => None,
515515
}
516516
},
517-
ty::ConstKind::Value(ConstValue::Slice { data, start, end }) => match result.ty.kind {
518-
ty::Ref(_, tam, _) => match tam.kind {
517+
ty::ConstKind::Value(ConstValue::Slice { data, start, end }) => match result.ty.kind() {
518+
ty::Ref(_, tam, _) => match tam.kind() {
519519
ty::Str => String::from_utf8(
520520
data.inspect_with_uninit_and_ptr_outside_interpreter(start..end)
521521
.to_owned(),
@@ -526,8 +526,8 @@ pub fn miri_to_const(result: &ty::Const<'_>) -> Option<Constant> {
526526
},
527527
_ => None,
528528
},
529-
ty::ConstKind::Value(ConstValue::ByRef { alloc, offset: _ }) => match result.ty.kind {
530-
ty::Array(sub_type, len) => match sub_type.kind {
529+
ty::ConstKind::Value(ConstValue::ByRef { alloc, offset: _ }) => match result.ty.kind() {
530+
ty::Array(sub_type, len) => match sub_type.kind() {
531531
ty::Float(FloatTy::F32) => match miri_to_const(len) {
532532
Some(Constant::Int(len)) => alloc
533533
.inspect_with_uninit_and_ptr_outside_interpreter(0..(4 * len as usize))

src/tools/clippy/clippy_lints/src/default_trait_access.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<'tcx> LateLintPass<'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.typeck_results().expr_ty(expr);
58-
if let ty::Adt(..) = expr_ty.kind {
58+
if let ty::Adt(..) = expr_ty.kind() {
5959
let replacement = format!("{}::default()", expr_ty);
6060
span_lint_and_sugg(
6161
cx,

src/tools/clippy/clippy_lints/src/derive.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -299,20 +299,20 @@ fn check_copy_clone<'tcx>(cx: &LateContext<'tcx>, item: &Item<'_>, trait_ref: &T
299299
return;
300300
}
301301

302-
match ty.kind {
302+
match *ty.kind() {
303303
ty::Adt(def, _) if def.is_union() => return,
304304

305305
// Some types are not Clone by default but could be cloned “by hand” if necessary
306306
ty::Adt(def, substs) => {
307307
for variant in &def.variants {
308308
for field in &variant.fields {
309-
if let ty::FnDef(..) = field.ty(cx.tcx, substs).kind {
309+
if let ty::FnDef(..) = field.ty(cx.tcx, substs).kind() {
310310
return;
311311
}
312312
}
313313
for subst in substs {
314314
if let ty::subst::GenericArgKind::Type(subst) = subst.unpack() {
315-
if let ty::Param(_) = subst.kind {
315+
if let ty::Param(_) = subst.kind() {
316316
return;
317317
}
318318
}
@@ -353,7 +353,7 @@ fn check_unsafe_derive_deserialize<'tcx>(
353353

354354
if_chain! {
355355
if match_path(&trait_ref.path, &paths::SERDE_DESERIALIZE);
356-
if let ty::Adt(def, _) = ty.kind;
356+
if let ty::Adt(def, _) = ty.kind();
357357
if let Some(local_def_id) = def.did.as_local();
358358
let adt_hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_def_id);
359359
if !is_allowed(cx, UNSAFE_DERIVE_DESERIALIZE, adt_hir_id);

src/tools/clippy/clippy_lints/src/doc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ fn lint_for_missing_headers<'tcx>(
239239
let mir = cx.tcx.optimized_mir(def_id.to_def_id());
240240
let ret_ty = mir.return_ty();
241241
if implements_trait(cx, ret_ty, future, &[]);
242-
if let ty::Opaque(_, subs) = ret_ty.kind;
242+
if let ty::Opaque(_, subs) = ret_ty.kind();
243243
if let Some(gen) = subs.types().next();
244-
if let ty::Generator(_, subs, _) = gen.kind;
244+
if let ty::Generator(_, subs, _) = gen.kind();
245245
if is_type_diagnostic_item(cx, subs.as_generator().return_ty(), sym!(result_type));
246246
then {
247247
span_lint(

src/tools/clippy/clippy_lints/src/drop_forget_ref.rs

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

124-
if let ty::Ref(..) = arg_ty.kind {
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();

src/tools/clippy/clippy_lints/src/enum_clike.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ impl<'tcx> LateLintPass<'tcx> for UnportableVariant {
5353
.ok()
5454
.map(|val| rustc_middle::ty::Const::from_value(cx.tcx, val, ty));
5555
if let Some(Constant::Int(val)) = constant.and_then(miri_to_const) {
56-
if let ty::Adt(adt, _) = ty.kind {
56+
if let ty::Adt(adt, _) = ty.kind() {
5757
if adt.is_enum() {
5858
ty = adt.repr.discr_type().to_ty(cx.tcx);
5959
}
6060
}
61-
match ty.kind {
61+
match ty.kind() {
6262
ty::Int(IntTy::Isize) => {
6363
let val = ((val as i128) << 64) >> 64;
6464
if i32::try_from(val).is_ok() {

src/tools/clippy/clippy_lints/src/eta_reduction.rs

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

100100
let fn_ty = cx.typeck_results().expr_ty(caller);
101101

102-
if matches!(fn_ty.kind, ty::FnDef(_, _) | ty::FnPtr(_) | ty::Closure(_, _));
102+
if matches!(fn_ty.kind(), ty::FnDef(_, _) | ty::FnPtr(_) | ty::Closure(_, _));
103103

104104
if !type_is_unsafe_function(cx, fn_ty);
105105

@@ -173,14 +173,14 @@ fn get_ufcs_type_name(cx: &LateContext<'_>, method_def_id: def_id::DefId, self_a
173173
}
174174

175175
fn match_borrow_depth(lhs: Ty<'_>, rhs: Ty<'_>) -> bool {
176-
match (&lhs.kind, &rhs.kind) {
176+
match (&lhs.kind(), &rhs.kind()) {
177177
(ty::Ref(_, t1, mut1), ty::Ref(_, t2, mut2)) => mut1 == mut2 && match_borrow_depth(&t1, &t2),
178178
(l, r) => !matches!((l, r), (ty::Ref(_, _, _), _) | (_, ty::Ref(_, _, _))),
179179
}
180180
}
181181

182182
fn match_types(lhs: Ty<'_>, rhs: Ty<'_>) -> bool {
183-
match (&lhs.kind, &rhs.kind) {
183+
match (&lhs.kind(), &rhs.kind()) {
184184
(ty::Bool, ty::Bool)
185185
| (ty::Char, ty::Char)
186186
| (ty::Int(_), ty::Int(_))
@@ -194,7 +194,7 @@ fn match_types(lhs: Ty<'_>, rhs: Ty<'_>) -> bool {
194194
}
195195

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

src/tools/clippy/clippy_lints/src/eval_order_dependence.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
138138
ExprKind::Continue(_) | ExprKind::Break(_, _) | ExprKind::Ret(_) => self.report_diverging_sub_expr(e),
139139
ExprKind::Call(ref func, _) => {
140140
let typ = self.cx.typeck_results().expr_ty(func);
141-
match typ.kind {
141+
match typ.kind() {
142142
ty::FnDef(..) | ty::FnPtr(_) => {
143143
let sig = typ.fn_sig(self.cx.tcx);
144-
if let ty::Never = self.cx.tcx.erase_late_bound_regions(&sig).output().kind {
144+
if let ty::Never = self.cx.tcx.erase_late_bound_regions(&sig).output().kind() {
145145
self.report_diverging_sub_expr(e);
146146
}
147147
},

0 commit comments

Comments
 (0)