@@ -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 }
@@ -338,9 +341,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
338341 [ sym:: coroutine, ..] => {
339342 self . check_coroutine ( attr, target) ;
340343 }
341- [ sym:: type_const, ..] => {
342- self . check_type_const ( hir_id, attr, target) ;
343- }
344344 [ sym:: linkage, ..] => self . check_linkage ( attr, span, target) ,
345345 [
346346 // ok
@@ -2513,7 +2513,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
25132513 }
25142514 }
25152515
2516- fn check_type_const ( & self , hir_id : HirId , attr : & Attribute , target : Target ) {
2516+ fn check_type_const ( & self , hir_id : HirId , attr_span : Span , target : Target ) {
25172517 let tcx = self . tcx ;
25182518 if target == Target :: AssocConst
25192519 && let parent = tcx. parent ( hir_id. expect_owner ( ) . to_def_id ( ) )
@@ -2523,7 +2523,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
25232523 } else {
25242524 self . dcx ( )
25252525 . struct_span_err (
2526- attr . span ( ) ,
2526+ attr_span ,
25272527 "`#[type_const]` must only be applied to trait associated constants" ,
25282528 )
25292529 . emit ( ) ;
0 commit comments