@@ -5,7 +5,7 @@ use std::sync::LazyLock;
55
66use itertools:: Itertools ;
77use private:: Sealed ;
8- use rustc_ast:: { self as ast, LitKind , MetaItemLit , NodeId } ;
8+ use rustc_ast:: { self as ast, AttrStyle , LitKind , MetaItemLit , NodeId } ;
99use rustc_errors:: { DiagCtxtHandle , Diagnostic } ;
1010use rustc_feature:: { AttributeTemplate , Features } ;
1111use rustc_hir:: attrs:: AttributeKind ;
@@ -315,6 +315,7 @@ pub struct AcceptContext<'f, 'sess, S: Stage> {
315315 /// The span of the attribute currently being parsed
316316 pub ( crate ) attr_span : Span ,
317317
318+ pub ( crate ) attr_style : AttrStyle ,
318319 /// The expected structure of the attribute.
319320 ///
320321 /// Used in reporting errors to give a hint to users what the attribute *should* look like.
@@ -396,6 +397,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
396397 i. kind . is_bytestr ( ) . then ( || self . sess ( ) . source_map ( ) . start_point ( i. span ) )
397398 } ) ,
398399 } ,
400+ attr_style : self . attr_style ,
399401 } )
400402 }
401403
@@ -406,6 +408,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
406408 template : self . template . clone ( ) ,
407409 attribute : self . attr_path . clone ( ) ,
408410 reason : AttributeParseErrorReason :: ExpectedIntegerLiteral ,
411+ attr_style : self . attr_style ,
409412 } )
410413 }
411414
@@ -416,6 +419,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
416419 template : self . template . clone ( ) ,
417420 attribute : self . attr_path . clone ( ) ,
418421 reason : AttributeParseErrorReason :: ExpectedList ,
422+ attr_style : self . attr_style ,
419423 } )
420424 }
421425
@@ -426,6 +430,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
426430 template : self . template . clone ( ) ,
427431 attribute : self . attr_path . clone ( ) ,
428432 reason : AttributeParseErrorReason :: ExpectedNoArgs ,
433+ attr_style : self . attr_style ,
429434 } )
430435 }
431436
@@ -437,6 +442,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
437442 template : self . template . clone ( ) ,
438443 attribute : self . attr_path . clone ( ) ,
439444 reason : AttributeParseErrorReason :: ExpectedIdentifier ,
445+ attr_style : self . attr_style ,
440446 } )
441447 }
442448
@@ -449,6 +455,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
449455 template : self . template . clone ( ) ,
450456 attribute : self . attr_path . clone ( ) ,
451457 reason : AttributeParseErrorReason :: ExpectedNameValue ( name) ,
458+ attr_style : self . attr_style ,
452459 } )
453460 }
454461
@@ -460,6 +467,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
460467 template : self . template . clone ( ) ,
461468 attribute : self . attr_path . clone ( ) ,
462469 reason : AttributeParseErrorReason :: DuplicateKey ( key) ,
470+ attr_style : self . attr_style ,
463471 } )
464472 }
465473
@@ -472,6 +480,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
472480 template : self . template . clone ( ) ,
473481 attribute : self . attr_path . clone ( ) ,
474482 reason : AttributeParseErrorReason :: UnexpectedLiteral ,
483+ attr_style : self . attr_style ,
475484 } )
476485 }
477486
@@ -482,6 +491,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
482491 template : self . template . clone ( ) ,
483492 attribute : self . attr_path . clone ( ) ,
484493 reason : AttributeParseErrorReason :: ExpectedSingleArgument ,
494+ attr_style : self . attr_style ,
485495 } )
486496 }
487497
@@ -492,6 +502,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
492502 template : self . template . clone ( ) ,
493503 attribute : self . attr_path . clone ( ) ,
494504 reason : AttributeParseErrorReason :: ExpectedAtLeastOneArgument ,
505+ attr_style : self . attr_style ,
495506 } )
496507 }
497508
@@ -510,6 +521,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
510521 strings : false ,
511522 list : false ,
512523 } ,
524+ attr_style : self . attr_style ,
513525 } )
514526 }
515527
@@ -528,6 +540,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
528540 strings : false ,
529541 list : true ,
530542 } ,
543+ attr_style : self . attr_style ,
531544 } )
532545 }
533546
@@ -546,6 +559,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
546559 strings : true ,
547560 list : false ,
548561 } ,
562+ attr_style : self . attr_style ,
549563 } )
550564 }
551565
@@ -804,6 +818,7 @@ impl<'sess> AttributeParser<'sess, Early> {
804818 } ,
805819 } ,
806820 attr_span : attr. span ,
821+ attr_style : attr. style ,
807822 template,
808823 attr_path : path. get_attribute_path ( ) ,
809824 } ;
@@ -914,6 +929,7 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
914929 emit_lint : & mut emit_lint,
915930 } ,
916931 attr_span : lower_span ( attr. span ) ,
932+ attr_style : attr. style ,
917933 template : & accept. template ,
918934 attr_path : path. get_attribute_path ( ) ,
919935 } ;
0 commit comments