@@ -129,6 +129,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
129129 ) => {
130130 self . check_must_be_applied_to_trait ( * attr_span, span, target) ;
131131 }
132+ & Attribute :: Parsed ( AttributeKind :: TypeConst ( attr_span) ) => {
133+ self . check_type_const ( hir_id, attr_span, target)
134+ }
132135 Attribute :: Parsed ( AttributeKind :: Confusables { first_span, .. } ) => {
133136 self . check_confusables ( * first_span, target) ;
134137 }
@@ -322,9 +325,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
322325 [ sym:: coroutine, ..] => {
323326 self . check_coroutine ( attr, target) ;
324327 }
325- [ sym:: type_const, ..] => {
326- self . check_type_const ( hir_id, attr, target) ;
327- }
328328 [ sym:: linkage, ..] => self . check_linkage ( attr, span, target) ,
329329 [
330330 // ok
@@ -2541,7 +2541,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
25412541 }
25422542 }
25432543
2544- fn check_type_const ( & self , hir_id : HirId , attr : & Attribute , target : Target ) {
2544+ fn check_type_const ( & self , hir_id : HirId , attr_span : Span , target : Target ) {
25452545 let tcx = self . tcx ;
25462546 if target == Target :: AssocConst
25472547 && let parent = tcx. parent ( hir_id. expect_owner ( ) . to_def_id ( ) )
@@ -2551,7 +2551,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
25512551 } else {
25522552 self . dcx ( )
25532553 . struct_span_err (
2554- attr . span ( ) ,
2554+ attr_span ,
25552555 "`#[type_const]` must only be applied to trait associated constants" ,
25562556 )
25572557 . emit ( ) ;
0 commit comments