@@ -786,18 +786,9 @@ fn check_item<'tcx>(
786786 // for trait impl blocks,
787787 // mark the method live if the self_ty is public,
788788 // or the method is public and may construct self
789- if of_trait
790- && ( !matches ! ( tcx. def_kind( local_def_id) , DefKind :: AssocFn )
791- || tcx. visibility ( local_def_id) . is_public ( )
792- && ( ty_is_pure_pub || may_construct_self) )
793- {
794- // if the impl item is public,
795- // and the ty may be constructed or can be constructed in foreign crates,
796- // mark the impl item live
797- worklist. push ( ( local_def_id, ComesFromAllowExpect :: No ) ) ;
798- } else if !of_trait
799- && tcx. visibility ( local_def_id) . is_public ( )
800- && ( ty_is_pure_pub || may_construct_self)
789+ if of_trait && matches ! ( tcx. def_kind( local_def_id) , DefKind :: AssocTy )
790+ || tcx. visibility ( local_def_id) . is_public ( )
791+ && ( ty_is_pure_pub || may_construct_self)
801792 {
802793 // if the impl item is public,
803794 // and the ty may be constructed or can be constructed in foreign crates,
@@ -882,7 +873,7 @@ fn create_and_seed_worklist(
882873 // checks impls, impl-items and pub structs with all public fields later
883874 match tcx. def_kind ( id) {
884875 DefKind :: Impl { .. } => false ,
885- DefKind :: AssocFn => !matches ! ( tcx. associated_item( id) . container, AssocItemContainer :: ImplContainer ) ,
876+ DefKind :: AssocConst | DefKind :: AssocFn => !matches ! ( tcx. associated_item( id) . container, AssocItemContainer :: ImplContainer ) ,
886877 DefKind :: Struct => struct_all_fields_are_public ( tcx, id. to_def_id ( ) ) ,
887878 _ => true
888879 } )
@@ -1158,13 +1149,13 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalModDefId) {
11581149 || ( def_kind == DefKind :: Trait && live_symbols. contains ( & item. owner_id . def_id ) )
11591150 {
11601151 for & def_id in tcx. associated_item_def_ids ( item. owner_id . def_id ) {
1161- // We have diagnosed unused methods in traits
1152+ // We have diagnosed unused assoc consts and fns in traits
11621153 if matches ! ( def_kind, DefKind :: Impl { of_trait: true } )
1163- && tcx. def_kind ( def_id) == DefKind :: AssocFn
1154+ && matches ! ( tcx. def_kind( def_id) , DefKind :: AssocConst | DefKind :: AssocFn )
11641155 // skip unused public inherent methods,
11651156 // cause we have diagnosed unconstructed struct
11661157 || matches ! ( def_kind, DefKind :: Impl { of_trait: false } ) && tcx. visibility ( def_id) . is_public ( ) && ty_ref_to_pub_struct ( tcx, tcx. hir ( ) . item ( item) . expect_impl ( ) . self_ty )
1167- || def_kind == DefKind :: Trait && tcx. def_kind ( def_id) != DefKind :: AssocFn
1158+ || def_kind == DefKind :: Trait && tcx. def_kind ( def_id) == DefKind :: AssocTy
11681159 {
11691160 continue ;
11701161 }
0 commit comments