Skip to content

Commit e3172d6

Browse files
More ty.kind -> ty.kind()
1 parent 20cb422 commit e3172d6

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

src/tools/clippy/clippy_lints/src/methods/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2569,9 +2569,9 @@ fn lint_map_flatten<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, map
25692569
// lint if caller of `.map().flatten()` is an Iterator
25702570
if match_trait_method(cx, expr, &paths::ITERATOR) {
25712571
let map_closure_ty = cx.typeck_results().expr_ty(&map_args[1]);
2572-
let is_map_to_option = match map_closure_ty.kind {
2572+
let is_map_to_option = match map_closure_ty.kind() {
25732573
ty::Closure(_, _) | ty::FnDef(_, _) | ty::FnPtr(_) => {
2574-
let map_closure_sig = match map_closure_ty.kind {
2574+
let map_closure_sig = match map_closure_ty.kind() {
25752575
ty::Closure(_, substs) => substs.as_closure().sig(),
25762576
_ => map_closure_ty.fn_sig(cx.tcx),
25772577
};

src/tools/clippy/clippy_lints/src/try_err.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ fn find_return_type<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx ExprKind<'_>) -> O
132132
/// Extracts the error type from Result<T, E>.
133133
fn result_error_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
134134
if_chain! {
135-
if let ty::Adt(_, subst) = ty.kind;
135+
if let ty::Adt(_, subst) = ty.kind();
136136
if is_type_diagnostic_item(cx, ty, sym!(result_type));
137137
let err_ty = subst.type_at(1);
138138
then {
@@ -146,11 +146,11 @@ fn result_error_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<Ty<'t
146146
/// Extracts the error type from Poll<Result<T, E>>.
147147
fn poll_result_error_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
148148
if_chain! {
149-
if let ty::Adt(def, subst) = ty.kind;
149+
if let ty::Adt(def, subst) = ty.kind();
150150
if match_def_path(cx, def.did, &paths::POLL);
151151
let ready_ty = subst.type_at(0);
152152

153-
if let ty::Adt(ready_def, ready_subst) = ready_ty.kind;
153+
if let ty::Adt(ready_def, ready_subst) = ready_ty.kind();
154154
if cx.tcx.is_diagnostic_item(sym!(result_type), ready_def.did);
155155
let err_ty = ready_subst.type_at(1);
156156

@@ -165,15 +165,15 @@ fn poll_result_error_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<
165165
/// Extracts the error type from Poll<Option<Result<T, E>>>.
166166
fn poll_option_result_error_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
167167
if_chain! {
168-
if let ty::Adt(def, subst) = ty.kind;
168+
if let ty::Adt(def, subst) = ty.kind();
169169
if match_def_path(cx, def.did, &paths::POLL);
170170
let ready_ty = subst.type_at(0);
171171

172-
if let ty::Adt(ready_def, ready_subst) = ready_ty.kind;
172+
if let ty::Adt(ready_def, ready_subst) = ready_ty.kind();
173173
if cx.tcx.is_diagnostic_item(sym!(option_type), ready_def.did);
174174
let some_ty = ready_subst.type_at(0);
175175

176-
if let ty::Adt(some_def, some_subst) = some_ty.kind;
176+
if let ty::Adt(some_def, some_subst) = some_ty.kind();
177177
if cx.tcx.is_diagnostic_item(sym!(result_type), some_def.did);
178178
let err_ty = some_subst.type_at(1);
179179

src/tools/clippy/clippy_lints/src/utils/mod.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,9 +1389,9 @@ pub fn run_lints(cx: &LateContext<'_>, lints: &[&'static Lint], id: HirId) -> bo
13891389
/// Returns true iff the given type is a primitive (a bool or char, any integer or floating-point
13901390
/// number type, a str, or an array, slice, or tuple of those types).
13911391
pub fn is_recursively_primitive_type(ty: Ty<'_>) -> bool {
1392-
match ty.kind {
1392+
match ty.kind() {
13931393
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Str => true,
1394-
ty::Ref(_, inner, _) if inner.kind == ty::Str => true,
1394+
ty::Ref(_, inner, _) if *inner.kind() == ty::Str => true,
13951395
ty::Array(inner_type, _) | ty::Slice(inner_type) => is_recursively_primitive_type(inner_type),
13961396
ty::Tuple(inner_types) => inner_types.types().all(is_recursively_primitive_type),
13971397
_ => false,
@@ -1402,16 +1402,15 @@ pub fn is_recursively_primitive_type(ty: Ty<'_>) -> bool {
14021402
/// `is_recursively_primitive_type` function).
14031403
pub fn is_slice_of_primitives(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
14041404
let expr_type = cx.typeck_results().expr_ty_adjusted(expr);
1405-
match expr_type.kind {
1406-
ty::Slice(ref element_type)
1407-
| ty::Ref(
1408-
_,
1409-
ty::TyS {
1410-
kind: ty::Slice(ref element_type),
1411-
..
1412-
},
1413-
_,
1414-
) => is_recursively_primitive_type(element_type),
1405+
match expr_type.kind() {
1406+
ty::Slice(ref element_type) => is_recursively_primitive_type(element_type),
1407+
ty::Ref(_, inner_ty, _) if matches!(inner_ty.kind(), &ty::Slice(_)) => {
1408+
if let ty::Slice(element_type) = *inner_ty.kind() {
1409+
is_recursively_primitive_type(element_type)
1410+
} else {
1411+
unreachable!()
1412+
}
1413+
}
14151414
_ => false,
14161415
}
14171416
}

0 commit comments

Comments
 (0)