Skip to content

Commit 2d8618e

Browse files
committed
Remove ty::TyKind from eta_reduction and replace it with ty::Ty
1 parent 8eadbfd commit 2d8618e

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

clippy_lints/src/eta_reduction.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -129,54 +129,54 @@ fn get_ufcs_type_name(
129129
method_def_id: def_id::DefId,
130130
self_arg: &Expr,
131131
) -> std::option::Option<String> {
132-
let expected_type_of_self = &cx.tcx.fn_sig(method_def_id).inputs_and_output().skip_binder()[0].sty;
133-
let actual_type_of_self = &cx.tables.node_type(self_arg.hir_id).sty;
132+
let expected_type_of_self = &cx.tcx.fn_sig(method_def_id).inputs_and_output().skip_binder()[0];
133+
let actual_type_of_self = &cx.tables.node_type(self_arg.hir_id);
134134

135135
if let Some(trait_id) = cx.tcx.trait_of_item(method_def_id) {
136-
if match_borrow_depth(expected_type_of_self, actual_type_of_self) {
136+
if match_borrow_depth(expected_type_of_self, &actual_type_of_self) {
137137
return Some(cx.tcx.def_path_str(trait_id));
138138
}
139139
}
140140

141141
cx.tcx.impl_of_method(method_def_id).and_then(|_| {
142142
//a type may implicitly implement other type's methods (e.g. Deref)
143-
if match_types(expected_type_of_self, actual_type_of_self) {
143+
if match_types(expected_type_of_self, &actual_type_of_self) {
144144
return Some(get_type_name(cx, &actual_type_of_self));
145145
}
146146
None
147147
})
148148
}
149149

150-
fn match_borrow_depth(lhs: &ty::TyKind<'_>, rhs: &ty::TyKind<'_>) -> bool {
151-
match (lhs, rhs) {
152-
(ty::Ref(_, t1, _), ty::Ref(_, t2, _)) => match_borrow_depth(&t1.sty, &t2.sty),
150+
fn match_borrow_depth(lhs: &ty::Ty<'_>, rhs: &ty::Ty<'_>) -> bool {
151+
match (&lhs.sty, &rhs.sty) {
152+
(ty::Ref(_, t1, _), ty::Ref(_, t2, _)) => match_borrow_depth(&t1, &t2),
153153
(l, r) => match (l, r) {
154154
(ty::Ref(_, _, _), _) | (_, ty::Ref(_, _, _)) => false,
155155
(_, _) => true,
156156
},
157157
}
158158
}
159159

160-
fn match_types(lhs: &ty::TyKind<'_>, rhs: &ty::TyKind<'_>) -> bool {
161-
match (lhs, rhs) {
160+
fn match_types(lhs: &ty::Ty<'_>, rhs: &ty::Ty<'_>) -> bool {
161+
match (&lhs.sty, &rhs.sty) {
162162
(ty::Bool, ty::Bool)
163163
| (ty::Char, ty::Char)
164164
| (ty::Int(_), ty::Int(_))
165165
| (ty::Uint(_), ty::Uint(_))
166166
| (ty::Str, ty::Str) => true,
167167
(ty::Ref(_, t1, _), ty::Ref(_, t2, _))
168168
| (ty::Array(t1, _), ty::Array(t2, _))
169-
| (ty::Slice(t1), ty::Slice(t2)) => match_types(&t1.sty, &t2.sty),
169+
| (ty::Slice(t1), ty::Slice(t2)) => match_types(&t1, &t2),
170170
(ty::Adt(def1, _), ty::Adt(def2, _)) => def1 == def2,
171171
(_, _) => false,
172172
}
173173
}
174174

175-
fn get_type_name(cx: &LateContext<'_, '_>, kind: &ty::TyKind<'_>) -> String {
176-
match kind {
175+
fn get_type_name(cx: &LateContext<'_, '_>, ty: &ty::Ty<'_>) -> String {
176+
match ty.sty {
177177
ty::Adt(t, _) => cx.tcx.def_path_str(t.did),
178-
ty::Ref(_, r, _) => get_type_name(cx, &r.sty),
179-
_ => kind.to_string(),
178+
ty::Ref(_, r, _) => get_type_name(cx, &r),
179+
_ => ty.to_string(),
180180
}
181181
}
182182

clippy_lints/src/transmute.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
347347
|db| {
348348
let arg = sugg::Sugg::hir(cx, &args[0], "..");
349349
let arg = if let ty::Int(_) = from_ty.sty {
350-
arg.as_ty(ty::Uint(ast::UintTy::U32))
350+
arg.as_ty(ast::UintTy::U32)
351351
} else {
352352
arg
353353
};

0 commit comments

Comments
 (0)