@@ -129,6 +129,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
129
129
) => {
130
130
self . check_must_be_applied_to_trait ( * attr_span, span, target) ;
131
131
}
132
+ & Attribute :: Parsed ( AttributeKind :: TypeConst ( attr_span) ) => {
133
+ self . check_type_const ( hir_id, attr_span, target)
134
+ }
132
135
Attribute :: Parsed ( AttributeKind :: Confusables { first_span, .. } ) => {
133
136
self . check_confusables ( * first_span, target) ;
134
137
}
@@ -315,9 +318,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
315
318
[ sym:: coroutine, ..] => {
316
319
self . check_coroutine ( attr, target) ;
317
320
}
318
- [ sym:: type_const, ..] => {
319
- self . check_type_const ( hir_id, attr, target) ;
320
- }
321
321
[ sym:: linkage, ..] => self . check_linkage ( attr, span, target) ,
322
322
[
323
323
// ok
@@ -2512,7 +2512,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
2512
2512
}
2513
2513
}
2514
2514
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 ) {
2516
2516
let tcx = self . tcx ;
2517
2517
if target == Target :: AssocConst
2518
2518
&& let parent = tcx. parent ( hir_id. expect_owner ( ) . to_def_id ( ) )
@@ -2522,7 +2522,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
2522
2522
} else {
2523
2523
self . dcx ( )
2524
2524
. struct_span_err (
2525
- attr . span ( ) ,
2525
+ attr_span ,
2526
2526
"`#[type_const]` must only be applied to trait associated constants" ,
2527
2527
)
2528
2528
. emit ( ) ;
0 commit comments