Skip to content

Commit bca1259

Browse files
committed
code review
1 parent fbdb13c commit bca1259

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

clippy_lints/src/mut_key.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fn check_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, span: Span, ty: Ty<'tcx>) {
103103
.iter()
104104
.any(|path| match_def_path(cx, def.did, &**path))
105105
{
106-
let key_type = concrete_type(Some(substs.type_at(0)));
106+
let key_type = concrete_type(substs.type_at(0));
107107
if let Some(key_type) = key_type {
108108
if !key_type.is_freeze(cx.tcx, cx.param_env, span) {
109109
span_lint(cx, MUTABLE_KEY_TYPE, span, "mutable key type");
@@ -113,13 +113,10 @@ fn check_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, span: Span, ty: Ty<'tcx>) {
113113
}
114114
}
115115

116-
fn concrete_type(ty: Option<Ty<'_>>) -> Option<Ty<'_>> {
117-
if let Some(ty) = ty {
118-
match ty.kind {
119-
RawPtr(TypeAndMut { ty: inner_ty, .. }) | Ref(_, inner_ty, _) => return concrete_type(Some(inner_ty)),
120-
Dynamic(..) | Opaque(..) | Param(..) => return None,
121-
_ => return Some(ty),
122-
}
116+
fn concrete_type(ty: Ty<'_>) -> Option<Ty<'_>> {
117+
match ty.kind {
118+
RawPtr(TypeAndMut { ty: inner_ty, .. }) | Ref(_, inner_ty, _) => concrete_type(inner_ty),
119+
Dynamic(..) | Opaque(..) | Param(..) => None,
120+
_ => Some(ty),
123121
}
124-
None
125122
}

0 commit comments

Comments
 (0)