11use super :: ERR_EXPECT ;
22use clippy_utils:: diagnostics:: span_lint_and_sugg;
33use clippy_utils:: msrvs:: { self , Msrv } ;
4- use clippy_utils:: res:: MaybeDef ;
54use clippy_utils:: ty:: has_debug_impl;
65use rustc_errors:: Applicability ;
76use rustc_lint:: LateContext ;
@@ -17,12 +16,10 @@ pub(super) fn check(
1716 err_span : Span ,
1817 msrv : Msrv ,
1918) {
20- if cx. typeck_results ( ) . expr_ty ( recv) . is_diag_item ( cx, sym:: Result )
21- // Grabs the `Result<T, E>` type
22- && let result_type = cx. typeck_results ( ) . expr_ty ( recv)
23- // Tests if the T type in a `Result<T, E>` is not None
24- && let Some ( data_type) = get_data_type ( cx, result_type)
25- // Tests if the T type in a `Result<T, E>` implements debug
19+ let result_ty = cx. typeck_results ( ) . expr_ty ( recv) ;
20+ // Grabs the `Result<T, E>` type
21+ if let Some ( data_type) = get_data_type ( cx, result_ty)
22+ // Tests if the T type in a `Result<T, E>` implements Debug
2623 && has_debug_impl ( cx, data_type)
2724 && msrv. meets ( cx, msrvs:: EXPECT_ERR )
2825 {
@@ -41,7 +38,7 @@ pub(super) fn check(
4138/// Given a `Result<T, E>` type, return its data (`T`).
4239fn get_data_type < ' a > ( cx : & LateContext < ' _ > , ty : Ty < ' a > ) -> Option < Ty < ' a > > {
4340 match ty. kind ( ) {
44- ty:: Adt ( _ , args) if ty . is_diag_item ( cx , sym:: Result ) => args. types ( ) . next ( ) ,
41+ ty:: Adt ( adt , args) if cx . tcx . is_diagnostic_item ( sym:: Result , adt . did ( ) ) => args. types ( ) . next ( ) ,
4542 _ => None ,
4643 }
4744}
0 commit comments