@@ -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
}
@@ -338,9 +341,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
338
341
[ sym:: coroutine, ..] => {
339
342
self . check_coroutine ( attr, target) ;
340
343
}
341
- [ sym:: type_const, ..] => {
342
- self . check_type_const ( hir_id, attr, target) ;
343
- }
344
344
[ sym:: linkage, ..] => self . check_linkage ( attr, span, target) ,
345
345
[
346
346
// ok
@@ -2513,7 +2513,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
2513
2513
}
2514
2514
}
2515
2515
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 ) {
2517
2517
let tcx = self . tcx ;
2518
2518
if target == Target :: AssocConst
2519
2519
&& let parent = tcx. parent ( hir_id. expect_owner ( ) . to_def_id ( ) )
@@ -2523,7 +2523,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
2523
2523
} else {
2524
2524
self . dcx ( )
2525
2525
. struct_span_err (
2526
- attr . span ( ) ,
2526
+ attr_span ,
2527
2527
"`#[type_const]` must only be applied to trait associated constants" ,
2528
2528
)
2529
2529
. emit ( ) ;
0 commit comments