@@ -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 ;
@@ -305,6 +305,7 @@ pub struct AcceptContext<'f, 'sess, S: Stage> {
305305 /// The span of the attribute currently being parsed
306306 pub ( crate ) attr_span : Span ,
307307
308+ pub ( crate ) attr_style : AttrStyle ,
308309 /// The expected structure of the attribute.
309310 ///
310311 /// Used in reporting errors to give a hint to users what the attribute *should* look like.
@@ -386,6 +387,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
386387 i. kind . is_bytestr ( ) . then ( || self . sess ( ) . source_map ( ) . start_point ( i. span ) )
387388 } ) ,
388389 } ,
390+ attr_style : self . attr_style ,
389391 } )
390392 }
391393
@@ -396,6 +398,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
396398 template : self . template . clone ( ) ,
397399 attribute : self . attr_path . clone ( ) ,
398400 reason : AttributeParseErrorReason :: ExpectedIntegerLiteral ,
401+ attr_style : self . attr_style ,
399402 } )
400403 }
401404
@@ -406,6 +409,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
406409 template : self . template . clone ( ) ,
407410 attribute : self . attr_path . clone ( ) ,
408411 reason : AttributeParseErrorReason :: ExpectedList ,
412+ attr_style : self . attr_style ,
409413 } )
410414 }
411415
@@ -416,6 +420,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
416420 template : self . template . clone ( ) ,
417421 attribute : self . attr_path . clone ( ) ,
418422 reason : AttributeParseErrorReason :: ExpectedNoArgs ,
423+ attr_style : self . attr_style ,
419424 } )
420425 }
421426
@@ -427,6 +432,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
427432 template : self . template . clone ( ) ,
428433 attribute : self . attr_path . clone ( ) ,
429434 reason : AttributeParseErrorReason :: ExpectedIdentifier ,
435+ attr_style : self . attr_style ,
430436 } )
431437 }
432438
@@ -439,6 +445,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
439445 template : self . template . clone ( ) ,
440446 attribute : self . attr_path . clone ( ) ,
441447 reason : AttributeParseErrorReason :: ExpectedNameValue ( name) ,
448+ attr_style : self . attr_style ,
442449 } )
443450 }
444451
@@ -450,6 +457,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
450457 template : self . template . clone ( ) ,
451458 attribute : self . attr_path . clone ( ) ,
452459 reason : AttributeParseErrorReason :: DuplicateKey ( key) ,
460+ attr_style : self . attr_style ,
453461 } )
454462 }
455463
@@ -462,6 +470,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
462470 template : self . template . clone ( ) ,
463471 attribute : self . attr_path . clone ( ) ,
464472 reason : AttributeParseErrorReason :: UnexpectedLiteral ,
473+ attr_style : self . attr_style ,
465474 } )
466475 }
467476
@@ -472,6 +481,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
472481 template : self . template . clone ( ) ,
473482 attribute : self . attr_path . clone ( ) ,
474483 reason : AttributeParseErrorReason :: ExpectedSingleArgument ,
484+ attr_style : self . attr_style ,
475485 } )
476486 }
477487
@@ -482,6 +492,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
482492 template : self . template . clone ( ) ,
483493 attribute : self . attr_path . clone ( ) ,
484494 reason : AttributeParseErrorReason :: ExpectedAtLeastOneArgument ,
495+ attr_style : self . attr_style ,
485496 } )
486497 }
487498
@@ -500,6 +511,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
500511 strings : false ,
501512 list : false ,
502513 } ,
514+ attr_style : self . attr_style ,
503515 } )
504516 }
505517
@@ -518,6 +530,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
518530 strings : false ,
519531 list : true ,
520532 } ,
533+ attr_style : self . attr_style ,
521534 } )
522535 }
523536
@@ -536,6 +549,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
536549 strings : true ,
537550 list : false ,
538551 } ,
552+ attr_style : self . attr_style ,
539553 } )
540554 }
541555
@@ -735,6 +749,7 @@ impl<'sess> AttributeParser<'sess, Early> {
735749 } ,
736750 } ,
737751 attr_span : attr. span ,
752+ attr_style : attr. style ,
738753 template,
739754 attr_path : path. get_attribute_path ( ) ,
740755 } ;
@@ -844,6 +859,7 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
844859 emit_lint : & mut emit_lint,
845860 } ,
846861 attr_span : lower_span ( attr. span ) ,
862+ attr_style : attr. style ,
847863 template : & accept. template ,
848864 attr_path : path. get_attribute_path ( ) ,
849865 } ;
0 commit comments