@@ -296,6 +296,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
296296 [ sym:: thread_local, ..] => self . check_thread_local ( attr, span, target) ,
297297 [ sym:: doc, ..] => self . check_doc_attrs (
298298 attr,
299+ attr. span ( ) ,
299300 attr_item. style ,
300301 hir_id,
301302 target,
@@ -1089,18 +1090,18 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
10891090 /// Checks that an attribute is used at the crate level. Returns `true` if valid.
10901091 fn check_attr_crate_level (
10911092 & self ,
1092- attr : & Attribute ,
1093+ attr_span : Span ,
10931094 style : AttrStyle ,
10941095 meta : & MetaItemInner ,
10951096 hir_id : HirId ,
10961097 ) -> bool {
10971098 if hir_id != CRATE_HIR_ID {
10981099 // insert a bang between `#` and `[...`
1099- let bang_span = attr . span ( ) . lo ( ) + BytePos ( 1 ) ;
1100+ let bang_span = attr_span . lo ( ) + BytePos ( 1 ) ;
11001101 let sugg = ( style == AttrStyle :: Outer
11011102 && self . tcx . hir_get_parent_item ( hir_id) == CRATE_OWNER_ID )
11021103 . then_some ( errors:: AttrCrateLevelOnlySugg {
1103- attr : attr . span ( ) . with_lo ( bang_span) . with_hi ( bang_span) ,
1104+ attr : attr_span . with_lo ( bang_span) . with_hi ( bang_span) ,
11041105 } ) ;
11051106 self . tcx . emit_node_span_lint (
11061107 INVALID_DOC_ATTRIBUTES ,
@@ -1116,7 +1117,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
11161117 /// Checks that `doc(test(...))` attribute contains only valid attributes and are at the right place.
11171118 fn check_test_attr (
11181119 & self ,
1119- attr : & Attribute ,
1120+ attr_span : Span ,
11201121 style : AttrStyle ,
11211122 meta : & MetaItemInner ,
11221123 hir_id : HirId ,
@@ -1128,7 +1129,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
11281129 // Allowed everywhere like `#[doc]`
11291130 }
11301131 ( Some ( sym:: no_crate_inject) , _) => {
1131- self . check_attr_crate_level ( attr , style, meta, hir_id) ;
1132+ self . check_attr_crate_level ( attr_span , style, meta, hir_id) ;
11321133 }
11331134 ( _, Some ( m) ) => {
11341135 self . tcx . emit_node_span_lint (
@@ -1225,6 +1226,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
12251226 fn check_doc_attrs (
12261227 & self ,
12271228 attr : & Attribute ,
1229+ attr_span : Span ,
12281230 style : AttrStyle ,
12291231 hir_id : HirId ,
12301232 target : Target ,
@@ -1274,7 +1276,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
12741276 }
12751277
12761278 Some ( sym:: test) => {
1277- self . check_test_attr ( attr , style, meta, hir_id) ;
1279+ self . check_test_attr ( attr_span , style, meta, hir_id) ;
12781280 }
12791281
12801282 Some (
@@ -1285,7 +1287,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
12851287 | sym:: html_root_url
12861288 | sym:: html_no_source,
12871289 ) => {
1288- self . check_attr_crate_level ( attr , style, meta, hir_id) ;
1290+ self . check_attr_crate_level ( attr_span , style, meta, hir_id) ;
12891291 }
12901292
12911293 Some ( sym:: auto_cfg) => {
@@ -1301,7 +1303,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
13011303 Some ( sym:: cfg | sym:: hidden | sym:: notable_trait) => { }
13021304
13031305 Some ( sym:: rust_logo) => {
1304- if self . check_attr_crate_level ( attr , style, meta, hir_id)
1306+ if self . check_attr_crate_level ( attr_span , style, meta, hir_id)
13051307 && !self . tcx . features ( ) . rustdoc_internals ( )
13061308 {
13071309 feature_err (
0 commit comments