@@ -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 }
@@ -324,9 +327,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
324327 [ sym:: coroutine, ..] => {
325328 self . check_coroutine ( attr, target) ;
326329 }
327- [ sym:: type_const, ..] => {
328- self . check_type_const ( hir_id, attr, target) ;
329- }
330330 [ sym:: linkage, ..] => self . check_linkage ( attr, span, target) ,
331331 [
332332 // 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