@@ -8,9 +8,10 @@ use clippy_utils::diagnostics::span_lint_and_note;
88use clippy_utils:: is_cfg_test;
99use rustc_attr_data_structures:: AttributeKind ;
1010use rustc_hir:: {
11- AssocItemKind , Attribute , FieldDef , HirId , ImplItemRef , IsAuto , Item , ItemKind , Mod , QPath , TraitItemRef , TyKind ,
11+ Attribute , FieldDef , HirId , ImplItemRef , IsAuto , Item , ItemKind , Mod , OwnerId , QPath , TraitItemRef , TyKind ,
1212 Variant , VariantData ,
1313} ;
14+ use rustc_middle:: ty:: AssocKind ;
1415use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
1516use rustc_session:: impl_lint_pass;
1617
@@ -315,9 +316,9 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
315316 }
316317
317318 if let Some ( cur_t) = cur_t {
318- let cur_t_kind = convert_assoc_item_kind ( cur_t. kind ) ;
319+ let cur_t_kind = convert_assoc_item_kind ( cx , cur_t. id . owner_id ) ;
319320 let cur_t_kind_index = self . assoc_types_order . index_of ( & cur_t_kind) ;
320- let item_kind = convert_assoc_item_kind ( item. kind ) ;
321+ let item_kind = convert_assoc_item_kind ( cx , item. id . owner_id ) ;
321322 let item_kind_index = self . assoc_types_order . index_of ( & item_kind) ;
322323
323324 if cur_t_kind == item_kind && cur_t. ident . name . as_str ( ) > item. ident . name . as_str ( ) {
@@ -338,9 +339,9 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
338339 }
339340
340341 if let Some ( cur_t) = cur_t {
341- let cur_t_kind = convert_assoc_item_kind ( cur_t. kind ) ;
342+ let cur_t_kind = convert_assoc_item_kind ( cx , cur_t. id . owner_id ) ;
342343 let cur_t_kind_index = self . assoc_types_order . index_of ( & cur_t_kind) ;
343- let item_kind = convert_assoc_item_kind ( item. kind ) ;
344+ let item_kind = convert_assoc_item_kind ( cx , item. id . owner_id ) ;
344345 let item_kind_index = self . assoc_types_order . index_of ( & item_kind) ;
345346
346347 if cur_t_kind == item_kind && cur_t. ident . name . as_str ( ) > item. ident . name . as_str ( ) {
@@ -458,18 +459,19 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
458459 }
459460}
460461
461- /// Converts a [`rustc_hir::AssocItemKind`] to a
462- /// [`SourceItemOrderingTraitAssocItemKind`].
462+ /// Converts a [`ty::AssocKind`] to a [`SourceItemOrderingTraitAssocItemKind`].
463463///
464464/// This is implemented here because `rustc_hir` is not a dependency of
465465/// `clippy_config`.
466- fn convert_assoc_item_kind ( value : AssocItemKind ) -> SourceItemOrderingTraitAssocItemKind {
466+ fn convert_assoc_item_kind ( cx : & LateContext < ' _ > , owner_id : OwnerId ) -> SourceItemOrderingTraitAssocItemKind {
467+ let kind = cx. tcx . associated_item ( owner_id. def_id ) . kind ;
468+
467469 #[ allow( clippy:: enum_glob_use) ] // Very local glob use for legibility.
468470 use SourceItemOrderingTraitAssocItemKind :: * ;
469- match value {
470- AssocItemKind :: Const => Const ,
471- AssocItemKind :: Type => Type ,
472- AssocItemKind :: Fn { .. } => Fn ,
471+ match kind {
472+ AssocKind :: Const { .. } => Const ,
473+ AssocKind :: Type { .. } => Type ,
474+ AssocKind :: Fn { .. } => Fn ,
473475 }
474476}
475477
0 commit comments