@@ -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 ;
@@ -304,6 +304,7 @@ pub struct AcceptContext<'f, 'sess, S: Stage> {
304304 /// The span of the attribute currently being parsed
305305 pub ( crate ) attr_span : Span ,
306306
307+ pub ( crate ) attr_style : AttrStyle ,
307308 /// The expected structure of the attribute.
308309 ///
309310 /// Used in reporting errors to give a hint to users what the attribute *should* look like.
@@ -385,6 +386,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
385386 i. kind . is_bytestr ( ) . then ( || self . sess ( ) . source_map ( ) . start_point ( i. span ) )
386387 } ) ,
387388 } ,
389+ attr_style : self . attr_style ,
388390 } )
389391 }
390392
@@ -395,6 +397,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
395397 template : self . template . clone ( ) ,
396398 attribute : self . attr_path . clone ( ) ,
397399 reason : AttributeParseErrorReason :: ExpectedIntegerLiteral ,
400+ attr_style : self . attr_style ,
398401 } )
399402 }
400403
@@ -405,6 +408,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
405408 template : self . template . clone ( ) ,
406409 attribute : self . attr_path . clone ( ) ,
407410 reason : AttributeParseErrorReason :: ExpectedList ,
411+ attr_style : self . attr_style ,
408412 } )
409413 }
410414
@@ -415,6 +419,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
415419 template : self . template . clone ( ) ,
416420 attribute : self . attr_path . clone ( ) ,
417421 reason : AttributeParseErrorReason :: ExpectedNoArgs ,
422+ attr_style : self . attr_style ,
418423 } )
419424 }
420425
@@ -426,6 +431,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
426431 template : self . template . clone ( ) ,
427432 attribute : self . attr_path . clone ( ) ,
428433 reason : AttributeParseErrorReason :: ExpectedIdentifier ,
434+ attr_style : self . attr_style ,
429435 } )
430436 }
431437
@@ -438,6 +444,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
438444 template : self . template . clone ( ) ,
439445 attribute : self . attr_path . clone ( ) ,
440446 reason : AttributeParseErrorReason :: ExpectedNameValue ( name) ,
447+ attr_style : self . attr_style ,
441448 } )
442449 }
443450
@@ -449,6 +456,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
449456 template : self . template . clone ( ) ,
450457 attribute : self . attr_path . clone ( ) ,
451458 reason : AttributeParseErrorReason :: DuplicateKey ( key) ,
459+ attr_style : self . attr_style ,
452460 } )
453461 }
454462
@@ -461,6 +469,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
461469 template : self . template . clone ( ) ,
462470 attribute : self . attr_path . clone ( ) ,
463471 reason : AttributeParseErrorReason :: UnexpectedLiteral ,
472+ attr_style : self . attr_style ,
464473 } )
465474 }
466475
@@ -471,6 +480,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
471480 template : self . template . clone ( ) ,
472481 attribute : self . attr_path . clone ( ) ,
473482 reason : AttributeParseErrorReason :: ExpectedSingleArgument ,
483+ attr_style : self . attr_style ,
474484 } )
475485 }
476486
@@ -481,6 +491,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
481491 template : self . template . clone ( ) ,
482492 attribute : self . attr_path . clone ( ) ,
483493 reason : AttributeParseErrorReason :: ExpectedAtLeastOneArgument ,
494+ attr_style : self . attr_style ,
484495 } )
485496 }
486497
@@ -499,6 +510,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
499510 strings : false ,
500511 list : false ,
501512 } ,
513+ attr_style : self . attr_style ,
502514 } )
503515 }
504516
@@ -517,6 +529,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
517529 strings : false ,
518530 list : true ,
519531 } ,
532+ attr_style : self . attr_style ,
520533 } )
521534 }
522535
@@ -535,6 +548,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
535548 strings : true ,
536549 list : false ,
537550 } ,
551+ attr_style : self . attr_style ,
538552 } )
539553 }
540554
@@ -734,6 +748,7 @@ impl<'sess> AttributeParser<'sess, Early> {
734748 } ,
735749 } ,
736750 attr_span : attr. span ,
751+ attr_style : attr. style ,
737752 template,
738753 attr_path : path. get_attribute_path ( ) ,
739754 } ;
@@ -843,6 +858,7 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
843858 emit_lint : & mut emit_lint,
844859 } ,
845860 attr_span : lower_span ( attr. span ) ,
861+ attr_style : attr. style ,
846862 template : & accept. template ,
847863 attr_path : path. get_attribute_path ( ) ,
848864 } ;
0 commit comments