@@ -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
}
@@ -322,9 +325,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
322
325
[ sym:: coroutine, ..] => {
323
326
self . check_coroutine ( attr, target) ;
324
327
}
325
- [ sym:: type_const, ..] => {
326
- self . check_type_const ( hir_id, attr, target) ;
327
- }
328
328
[ sym:: linkage, ..] => self . check_linkage ( attr, span, target) ,
329
329
[
330
330
// ok
@@ -2541,7 +2541,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
2541
2541
}
2542
2542
}
2543
2543
2544
- fn check_type_const ( & self , hir_id : HirId , attr : & Attribute , target : Target ) {
2544
+ fn check_type_const ( & self , hir_id : HirId , attr_span : Span , target : Target ) {
2545
2545
let tcx = self . tcx ;
2546
2546
if target == Target :: AssocConst
2547
2547
&& let parent = tcx. parent ( hir_id. expect_owner ( ) . to_def_id ( ) )
@@ -2551,7 +2551,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
2551
2551
} else {
2552
2552
self . dcx ( )
2553
2553
. struct_span_err (
2554
- attr . span ( ) ,
2554
+ attr_span ,
2555
2555
"`#[type_const]` must only be applied to trait associated constants" ,
2556
2556
)
2557
2557
. emit ( ) ;
0 commit comments