@@ -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
}
@@ -330,9 +333,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
330
333
[ sym:: coroutine, ..] => {
331
334
self . check_coroutine ( attr, target) ;
332
335
}
333
- [ sym:: type_const, ..] => {
334
- self . check_type_const ( hir_id, attr, target) ;
335
- }
336
336
[ sym:: linkage, ..] => self . check_linkage ( attr, span, target) ,
337
337
[
338
338
// ok
@@ -2508,7 +2508,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
2508
2508
}
2509
2509
}
2510
2510
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 ) {
2512
2512
let tcx = self . tcx ;
2513
2513
if target == Target :: AssocConst
2514
2514
&& let parent = tcx. parent ( hir_id. expect_owner ( ) . to_def_id ( ) )
@@ -2518,7 +2518,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
2518
2518
} else {
2519
2519
self . dcx ( )
2520
2520
. struct_span_err (
2521
- attr . span ( ) ,
2521
+ attr_span ,
2522
2522
"`#[type_const]` must only be applied to trait associated constants" ,
2523
2523
)
2524
2524
. emit ( ) ;
0 commit comments