1
1
use clippy_utils:: diagnostics:: span_lint_and_then;
2
2
use clippy_utils:: msrvs:: { self , Msrv } ;
3
- use clippy_utils:: { expr_or_init, paths } ;
3
+ use clippy_utils:: { expr_or_init, is_path_diagnostic_item , sym } ;
4
4
use rustc_errors:: Applicability ;
5
5
use rustc_hir:: { Expr , ExprKind , QPath } ;
6
6
use rustc_lint:: LateContext ;
@@ -10,8 +10,11 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, path: &Expr<'_>, args
10
10
&& !expr. span . from_expansion ( )
11
11
&& !error_kind. span . from_expansion ( )
12
12
&& let ExprKind :: Path ( QPath :: TypeRelative ( _, new_segment) ) = path. kind
13
- && paths:: IO_ERROR_NEW . matches_path ( cx, path)
14
- && paths:: IO_ERRORKIND_OTHER_CTOR . matches_path ( cx, expr_or_init ( cx, error_kind) )
13
+ && is_path_diagnostic_item ( cx, path, sym:: io_error_new)
14
+ && let ExprKind :: Path ( QPath :: Resolved ( _, init_path) ) = & expr_or_init ( cx, error_kind) . kind
15
+ && let [ .., error_kind_ty, error_kind_variant] = init_path. segments
16
+ && cx. tcx . is_diagnostic_item ( sym:: io_errorkind, error_kind_ty. res . def_id ( ) )
17
+ && error_kind_variant. ident . name == sym:: Other
15
18
&& msrv. meets ( cx, msrvs:: IO_ERROR_OTHER )
16
19
{
17
20
span_lint_and_then (
0 commit comments