@@ -85,11 +85,6 @@ pub(super) fn check<'tcx>(
85
85
}
86
86
}
87
87
88
- // skip cast of fn call that returns type alias
89
- if let ExprKind :: Cast ( inner, ..) = expr. kind && is_cast_from_ty_alias ( cx, inner, cast_from) {
90
- return false ;
91
- }
92
-
93
88
// skip cast to non-primitive type
94
89
if_chain ! {
95
90
if let ExprKind :: Cast ( _, cast_to) = expr. kind;
@@ -101,6 +96,11 @@ pub(super) fn check<'tcx>(
101
96
}
102
97
}
103
98
99
+ // skip cast of fn call that returns type alias
100
+ if let ExprKind :: Cast ( inner, ..) = expr. kind && is_cast_from_ty_alias ( cx, inner, cast_from) {
101
+ return false ;
102
+ }
103
+
104
104
if let Some ( lit) = get_numeric_literal ( cast_expr) {
105
105
let literal_str = & cast_str;
106
106
@@ -269,6 +269,7 @@ fn is_cast_from_ty_alias<'tcx>(cx: &LateContext<'tcx>, expr: impl Visitable<'tcx
269
269
|| s. trim ( ) . contains ( & format ! ( "::{cast_from}" ) )
270
270
} )
271
271
} )
272
+ . map ( |s| snippet_eq_ty ( s, cast_from) || s. split ( "where" ) . any ( |ty| snippet_eq_ty ( ty, cast_from) ) )
272
273
. any ( |a| a)
273
274
{
274
275
return ControlFlow :: Break ( ( ) ) ;
@@ -295,3 +296,7 @@ fn is_cast_from_ty_alias<'tcx>(cx: &LateContext<'tcx>, expr: impl Visitable<'tcx
295
296
} )
296
297
. is_some ( )
297
298
}
299
+
300
+ fn snippet_eq_ty ( snippet : & str , ty : Ty < ' _ > ) -> bool {
301
+ snippet. trim ( ) == ty. to_string ( ) || snippet. trim ( ) . contains ( & format ! ( "::{ty}" ) )
302
+ }
0 commit comments