@@ -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 }
@@ -330,9 +333,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
330333 [ sym:: coroutine, ..] => {
331334 self . check_coroutine ( attr, target) ;
332335 }
333- [ sym:: type_const, ..] => {
334- self . check_type_const ( hir_id, attr, target) ;
335- }
336336 [ sym:: linkage, ..] => self . check_linkage ( attr, span, target) ,
337337 [
338338 // ok
@@ -2508,7 +2508,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
25082508 }
25092509 }
25102510
2511- fn check_type_const ( & self , hir_id : HirId , attr : & Attribute , target : Target ) {
2511+ fn check_type_const ( & self , hir_id : HirId , attr_span : Span , target : Target ) {
25122512 let tcx = self . tcx ;
25132513 if target == Target :: AssocConst
25142514 && let parent = tcx. parent ( hir_id. expect_owner ( ) . to_def_id ( ) )
@@ -2518,7 +2518,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
25182518 } else {
25192519 self . dcx ( )
25202520 . struct_span_err (
2521- attr . span ( ) ,
2521+ attr_span ,
25222522 "`#[type_const]` must only be applied to trait associated constants" ,
25232523 )
25242524 . emit ( ) ;
0 commit comments