@@ -4,7 +4,7 @@ use std::ops::{Deref, DerefMut};
44use std:: sync:: LazyLock ;
55
66use private:: Sealed ;
7- use rustc_ast:: { self as ast, LitKind , MetaItemLit , NodeId } ;
7+ use rustc_ast:: { self as ast, AttrStyle , LitKind , MetaItemLit , NodeId } ;
88use rustc_errors:: { DiagCtxtHandle , Diagnostic } ;
99use rustc_feature:: { AttributeTemplate , Features } ;
1010use rustc_hir:: attrs:: AttributeKind ;
@@ -301,6 +301,7 @@ pub struct AcceptContext<'f, 'sess, S: Stage> {
301301 /// The span of the attribute currently being parsed
302302 pub ( crate ) attr_span : Span ,
303303
304+ pub ( crate ) attr_style : AttrStyle ,
304305 /// The expected structure of the attribute.
305306 ///
306307 /// Used in reporting errors to give a hint to users what the attribute *should* look like.
@@ -382,6 +383,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
382383 i. kind . is_bytestr ( ) . then ( || self . sess ( ) . source_map ( ) . start_point ( i. span ) )
383384 } ) ,
384385 } ,
386+ attr_style : self . attr_style ,
385387 } )
386388 }
387389
@@ -392,6 +394,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
392394 template : self . template . clone ( ) ,
393395 attribute : self . attr_path . clone ( ) ,
394396 reason : AttributeParseErrorReason :: ExpectedIntegerLiteral ,
397+ attr_style : self . attr_style ,
395398 } )
396399 }
397400
@@ -402,6 +405,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
402405 template : self . template . clone ( ) ,
403406 attribute : self . attr_path . clone ( ) ,
404407 reason : AttributeParseErrorReason :: ExpectedList ,
408+ attr_style : self . attr_style ,
405409 } )
406410 }
407411
@@ -412,6 +416,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
412416 template : self . template . clone ( ) ,
413417 attribute : self . attr_path . clone ( ) ,
414418 reason : AttributeParseErrorReason :: ExpectedNoArgs ,
419+ attr_style : self . attr_style ,
415420 } )
416421 }
417422
@@ -423,6 +428,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
423428 template : self . template . clone ( ) ,
424429 attribute : self . attr_path . clone ( ) ,
425430 reason : AttributeParseErrorReason :: ExpectedIdentifier ,
431+ attr_style : self . attr_style ,
426432 } )
427433 }
428434
@@ -435,6 +441,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
435441 template : self . template . clone ( ) ,
436442 attribute : self . attr_path . clone ( ) ,
437443 reason : AttributeParseErrorReason :: ExpectedNameValue ( name) ,
444+ attr_style : self . attr_style ,
438445 } )
439446 }
440447
@@ -446,6 +453,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
446453 template : self . template . clone ( ) ,
447454 attribute : self . attr_path . clone ( ) ,
448455 reason : AttributeParseErrorReason :: DuplicateKey ( key) ,
456+ attr_style : self . attr_style ,
449457 } )
450458 }
451459
@@ -458,6 +466,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
458466 template : self . template . clone ( ) ,
459467 attribute : self . attr_path . clone ( ) ,
460468 reason : AttributeParseErrorReason :: UnexpectedLiteral ,
469+ attr_style : self . attr_style ,
461470 } )
462471 }
463472
@@ -468,6 +477,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
468477 template : self . template . clone ( ) ,
469478 attribute : self . attr_path . clone ( ) ,
470479 reason : AttributeParseErrorReason :: ExpectedSingleArgument ,
480+ attr_style : self . attr_style ,
471481 } )
472482 }
473483
@@ -478,6 +488,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
478488 template : self . template . clone ( ) ,
479489 attribute : self . attr_path . clone ( ) ,
480490 reason : AttributeParseErrorReason :: ExpectedAtLeastOneArgument ,
491+ attr_style : self . attr_style ,
481492 } )
482493 }
483494
@@ -496,6 +507,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
496507 strings : false ,
497508 list : false ,
498509 } ,
510+ attr_style : self . attr_style ,
499511 } )
500512 }
501513
@@ -514,6 +526,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
514526 strings : false ,
515527 list : true ,
516528 } ,
529+ attr_style : self . attr_style ,
517530 } )
518531 }
519532
@@ -532,6 +545,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
532545 strings : true ,
533546 list : false ,
534547 } ,
548+ attr_style : self . attr_style ,
535549 } )
536550 }
537551
@@ -731,6 +745,7 @@ impl<'sess> AttributeParser<'sess, Early> {
731745 } ,
732746 } ,
733747 attr_span : attr. span ,
748+ attr_style : attr. style ,
734749 template,
735750 attr_path : path. get_attribute_path ( ) ,
736751 } ;
@@ -840,6 +855,7 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
840855 emit_lint : & mut emit_lint,
841856 } ,
842857 attr_span : lower_span ( attr. span ) ,
858+ attr_style : attr. style ,
843859 template : & accept. template ,
844860 attr_path : path. get_attribute_path ( ) ,
845861 } ;
0 commit comments