@@ -36,15 +36,12 @@ declare_lint_pass!(ErrorImplError => [ERROR_IMPL_ERROR]);
3636
3737impl < ' tcx > LateLintPass < ' tcx > for ErrorImplError {
3838 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-
4339 match item. kind {
4440 ItemKind :: TyAlias ( ..)
4541 if item. ident . name == sym:: Error
4642 && is_visible_outside_module ( cx, item. owner_id . def_id )
4743 && let ty = cx. tcx . type_of ( item. owner_id ) . instantiate_identity ( )
44+ && let Some ( error_def_id) = cx. tcx . get_diagnostic_item ( sym:: Error )
4845 && implements_trait ( cx, ty, error_def_id, & [ ] ) =>
4946 {
5047 span_lint (
@@ -56,17 +53,17 @@ impl<'tcx> LateLintPass<'tcx> for ErrorImplError {
5653 } ,
5754 ItemKind :: Impl ( imp)
5855 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 )
5957 && error_def_id == trait_def_id
6058 && 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)
6259 && let Some ( ident) = cx. tcx . opt_item_ident ( def_id. to_def_id ( ) )
6360 && ident. name == sym:: Error
6461 && is_visible_outside_module ( cx, def_id) =>
6562 {
6663 span_lint_hir_and_then (
6764 cx,
6865 ERROR_IMPL_ERROR ,
69- hir_id ,
66+ cx . tcx . local_def_id_to_hir_id ( def_id ) ,
7067 ident. span ,
7168 "exported type named `Error` that implements `Error`" ,
7269 |diag| {
0 commit comments