Skip to content

Commit d0de0ec

Browse files
committed
use result_error_type
1 parent 79a95ee commit d0de0ec

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

clippy_lints/src/matches/try_err.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,9 @@ fn result_error_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<Ty<'t
101101
fn poll_result_error_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
102102
if let ty::Adt(def, subst) = ty.kind()
103103
&& cx.tcx.lang_items().get(LangItem::Poll) == Some(def.did())
104-
&& let ready_ty = subst.type_at(0)
105-
&& let ty::Adt(ready_def, ready_subst) = ready_ty.kind()
106-
&& cx.tcx.is_diagnostic_item(sym::Result, ready_def.did())
107104
{
108-
Some(ready_subst.type_at(1))
105+
let ready_ty = subst.type_at(0);
106+
result_error_type(cx, ready_ty)
109107
} else {
110108
None
111109
}
@@ -117,10 +115,8 @@ fn poll_option_result_error_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) ->
117115
&& cx.tcx.lang_items().get(LangItem::Poll) == Some(def.did())
118116
&& let ready_ty = subst.type_at(0)
119117
&& let Some(some_ty) = option_arg_ty(cx, ready_ty)
120-
&& let ty::Adt(some_def, some_subst) = some_ty.kind()
121-
&& cx.tcx.is_diagnostic_item(sym::Result, some_def.did())
122118
{
123-
Some(some_subst.type_at(1))
119+
result_error_type(cx, some_ty)
124120
} else {
125121
None
126122
}

0 commit comments

Comments
 (0)