@@ -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 ;
@@ -313,6 +313,7 @@ pub struct AcceptContext<'f, 'sess, S: Stage> {
313313 /// The span of the attribute currently being parsed
314314 pub ( crate ) attr_span : Span ,
315315
316+ pub ( crate ) attr_style : AttrStyle ,
316317 /// The expected structure of the attribute.
317318 ///
318319 /// Used in reporting errors to give a hint to users what the attribute *should* look like.
@@ -394,6 +395,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
394395 i. kind . is_bytestr ( ) . then ( || self . sess ( ) . source_map ( ) . start_point ( i. span ) )
395396 } ) ,
396397 } ,
398+ attr_style : self . attr_style ,
397399 } )
398400 }
399401
@@ -404,6 +406,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
404406 template : self . template . clone ( ) ,
405407 attribute : self . attr_path . clone ( ) ,
406408 reason : AttributeParseErrorReason :: ExpectedIntegerLiteral ,
409+ attr_style : self . attr_style ,
407410 } )
408411 }
409412
@@ -414,6 +417,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
414417 template : self . template . clone ( ) ,
415418 attribute : self . attr_path . clone ( ) ,
416419 reason : AttributeParseErrorReason :: ExpectedList ,
420+ attr_style : self . attr_style ,
417421 } )
418422 }
419423
@@ -424,6 +428,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
424428 template : self . template . clone ( ) ,
425429 attribute : self . attr_path . clone ( ) ,
426430 reason : AttributeParseErrorReason :: ExpectedNoArgs ,
431+ attr_style : self . attr_style ,
427432 } )
428433 }
429434
@@ -435,6 +440,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
435440 template : self . template . clone ( ) ,
436441 attribute : self . attr_path . clone ( ) ,
437442 reason : AttributeParseErrorReason :: ExpectedIdentifier ,
443+ attr_style : self . attr_style ,
438444 } )
439445 }
440446
@@ -447,6 +453,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
447453 template : self . template . clone ( ) ,
448454 attribute : self . attr_path . clone ( ) ,
449455 reason : AttributeParseErrorReason :: ExpectedNameValue ( name) ,
456+ attr_style : self . attr_style ,
450457 } )
451458 }
452459
@@ -458,6 +465,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
458465 template : self . template . clone ( ) ,
459466 attribute : self . attr_path . clone ( ) ,
460467 reason : AttributeParseErrorReason :: DuplicateKey ( key) ,
468+ attr_style : self . attr_style ,
461469 } )
462470 }
463471
@@ -470,6 +478,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
470478 template : self . template . clone ( ) ,
471479 attribute : self . attr_path . clone ( ) ,
472480 reason : AttributeParseErrorReason :: UnexpectedLiteral ,
481+ attr_style : self . attr_style ,
473482 } )
474483 }
475484
@@ -480,6 +489,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
480489 template : self . template . clone ( ) ,
481490 attribute : self . attr_path . clone ( ) ,
482491 reason : AttributeParseErrorReason :: ExpectedSingleArgument ,
492+ attr_style : self . attr_style ,
483493 } )
484494 }
485495
@@ -490,6 +500,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
490500 template : self . template . clone ( ) ,
491501 attribute : self . attr_path . clone ( ) ,
492502 reason : AttributeParseErrorReason :: ExpectedAtLeastOneArgument ,
503+ attr_style : self . attr_style ,
493504 } )
494505 }
495506
@@ -508,6 +519,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
508519 strings : false ,
509520 list : false ,
510521 } ,
522+ attr_style : self . attr_style ,
511523 } )
512524 }
513525
@@ -526,6 +538,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
526538 strings : false ,
527539 list : true ,
528540 } ,
541+ attr_style : self . attr_style ,
529542 } )
530543 }
531544
@@ -544,6 +557,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
544557 strings : true ,
545558 list : false ,
546559 } ,
560+ attr_style : self . attr_style ,
547561 } )
548562 }
549563
@@ -802,6 +816,7 @@ impl<'sess> AttributeParser<'sess, Early> {
802816 } ,
803817 } ,
804818 attr_span : attr. span ,
819+ attr_style : attr. style ,
805820 template,
806821 attr_path : path. get_attribute_path ( ) ,
807822 } ;
@@ -912,6 +927,7 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
912927 emit_lint : & mut emit_lint,
913928 } ,
914929 attr_span : lower_span ( attr. span ) ,
930+ attr_style : attr. style ,
915931 template : & accept. template ,
916932 attr_path : path. get_attribute_path ( ) ,
917933 } ;
0 commit comments