@@ -36,15 +36,12 @@ declare_lint_pass!(ErrorImplError => [ERROR_IMPL_ERROR]);
36
36
37
37
impl < ' tcx > LateLintPass < ' tcx > for ErrorImplError {
38
38
fn check_item ( & mut self , cx : & LateContext < ' tcx > , item : & ' tcx Item < ' tcx > ) {
39
- let Some ( error_def_id) = cx. tcx . get_diagnostic_item ( sym:: Error ) else {
40
- return ;
41
- } ;
42
-
43
39
match item. kind {
44
40
ItemKind :: TyAlias ( ..)
45
41
if item. ident . name == sym:: Error
46
42
&& is_visible_outside_module ( cx, item. owner_id . def_id )
47
43
&& let ty = cx. tcx . type_of ( item. owner_id ) . instantiate_identity ( )
44
+ && let Some ( error_def_id) = cx. tcx . get_diagnostic_item ( sym:: Error )
48
45
&& implements_trait ( cx, ty, error_def_id, & [ ] ) =>
49
46
{
50
47
span_lint (
@@ -56,17 +53,17 @@ impl<'tcx> LateLintPass<'tcx> for ErrorImplError {
56
53
} ,
57
54
ItemKind :: Impl ( imp)
58
55
if let Some ( trait_def_id) = imp. of_trait . and_then ( |t| t. trait_def_id ( ) )
56
+ && let Some ( error_def_id) = cx. tcx . get_diagnostic_item ( sym:: Error )
59
57
&& error_def_id == trait_def_id
60
58
&& let Some ( def_id) = path_res ( cx, imp. self_ty ) . opt_def_id ( ) . and_then ( DefId :: as_local)
61
- && let hir_id = cx. tcx . local_def_id_to_hir_id ( def_id)
62
59
&& let Some ( ident) = cx. tcx . opt_item_ident ( def_id. to_def_id ( ) )
63
60
&& ident. name == sym:: Error
64
61
&& is_visible_outside_module ( cx, def_id) =>
65
62
{
66
63
span_lint_hir_and_then (
67
64
cx,
68
65
ERROR_IMPL_ERROR ,
69
- hir_id ,
66
+ cx . tcx . local_def_id_to_hir_id ( def_id ) ,
70
67
ident. span ,
71
68
"exported type named `Error` that implements `Error`" ,
72
69
|diag| {
0 commit comments