@@ -60,9 +60,7 @@ impl NonConstExpr {
6060fn check_mod_const_bodies ( tcx : TyCtxt < ' _ > , module_def_id : LocalDefId ) {
6161 let mut vis = CheckConstVisitor :: new ( tcx) ;
6262 tcx. hir ( ) . visit_item_likes_in_module ( module_def_id, & mut vis. as_deep_visitor ( ) ) ;
63- if tcx. features ( ) . enabled ( sym:: const_trait_impl) {
64- tcx. hir ( ) . visit_item_likes_in_module ( module_def_id, & mut CheckConstTraitVisitor :: new ( tcx) ) ;
65- }
63+ tcx. hir ( ) . visit_item_likes_in_module ( module_def_id, & mut CheckConstTraitVisitor :: new ( tcx) ) ;
6664}
6765
6866pub ( crate ) fn provide ( providers : & mut Providers ) {
@@ -80,6 +78,8 @@ impl<'tcx> CheckConstTraitVisitor<'tcx> {
8078}
8179
8280impl < ' tcx > hir:: itemlikevisit:: ItemLikeVisitor < ' tcx > for CheckConstTraitVisitor < ' tcx > {
81+ /// check for const trait impls, and errors if the impl uses provided/default functions
82+ /// of the trait being implemented; as those provided functions can be non-const.
8383 fn visit_item ( & mut self , item : & ' hir hir:: Item < ' hir > ) {
8484 let _: Option < _ > = try {
8585 if let hir:: ItemKind :: Impl ( ref imp) = item. kind {
@@ -103,6 +103,9 @@ impl<'tcx> hir::itemlikevisit::ItemLikeVisitor<'tcx> for CheckConstTraitVisitor<
103103 . filter ( |it| matches ! ( it. kind, hir:: AssocItemKind :: Fn { .. } ) )
104104 . count ( ) ;
105105
106+ // number of trait functions unequal to functions in impl,
107+ // meaning that one or more provided/default functions of the
108+ // trait are used.
106109 if trait_fn_cnt != impl_fn_cnt {
107110 self . tcx
108111 . sess
0 commit comments