@@ -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 }
@@ -315,9 +318,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
315318 [ sym:: coroutine, ..] => {
316319 self . check_coroutine ( attr, target) ;
317320 }
318- [ sym:: type_const, ..] => {
319- self . check_type_const ( hir_id, attr, target) ;
320- }
321321 [ sym:: linkage, ..] => self . check_linkage ( attr, span, target) ,
322322 [
323323 // ok
@@ -2512,7 +2512,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
25122512 }
25132513 }
25142514
2515- fn check_type_const ( & self , hir_id : HirId , attr : & Attribute , target : Target ) {
2515+ fn check_type_const ( & self , hir_id : HirId , attr_span : Span , target : Target ) {
25162516 let tcx = self . tcx ;
25172517 if target == Target :: AssocConst
25182518 && let parent = tcx. parent ( hir_id. expect_owner ( ) . to_def_id ( ) )
@@ -2522,7 +2522,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
25222522 } else {
25232523 self . dcx ( )
25242524 . struct_span_err (
2525- attr . span ( ) ,
2525+ attr_span ,
25262526 "`#[type_const]` must only be applied to trait associated constants" ,
25272527 )
25282528 . emit ( ) ;
0 commit comments