@@ -4,7 +4,7 @@ use std::ops::{Deref, DerefMut};
4
4
use std:: sync:: LazyLock ;
5
5
6
6
use private:: Sealed ;
7
- use rustc_ast:: { self as ast, LitKind , MetaItemLit , NodeId } ;
7
+ use rustc_ast:: { self as ast, AttrStyle , LitKind , MetaItemLit , NodeId } ;
8
8
use rustc_errors:: { DiagCtxtHandle , Diagnostic } ;
9
9
use rustc_feature:: { AttributeTemplate , Features } ;
10
10
use rustc_hir:: attrs:: AttributeKind ;
@@ -305,6 +305,7 @@ pub struct AcceptContext<'f, 'sess, S: Stage> {
305
305
/// The span of the attribute currently being parsed
306
306
pub ( crate ) attr_span : Span ,
307
307
308
+ pub ( crate ) attr_style : AttrStyle ,
308
309
/// The expected structure of the attribute.
309
310
///
310
311
/// 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> {
386
387
i. kind . is_bytestr ( ) . then ( || self . sess ( ) . source_map ( ) . start_point ( i. span ) )
387
388
} ) ,
388
389
} ,
390
+ attr_style : self . attr_style ,
389
391
} )
390
392
}
391
393
@@ -396,6 +398,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
396
398
template : self . template . clone ( ) ,
397
399
attribute : self . attr_path . clone ( ) ,
398
400
reason : AttributeParseErrorReason :: ExpectedIntegerLiteral ,
401
+ attr_style : self . attr_style ,
399
402
} )
400
403
}
401
404
@@ -406,6 +409,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
406
409
template : self . template . clone ( ) ,
407
410
attribute : self . attr_path . clone ( ) ,
408
411
reason : AttributeParseErrorReason :: ExpectedList ,
412
+ attr_style : self . attr_style ,
409
413
} )
410
414
}
411
415
@@ -416,6 +420,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
416
420
template : self . template . clone ( ) ,
417
421
attribute : self . attr_path . clone ( ) ,
418
422
reason : AttributeParseErrorReason :: ExpectedNoArgs ,
423
+ attr_style : self . attr_style ,
419
424
} )
420
425
}
421
426
@@ -427,6 +432,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
427
432
template : self . template . clone ( ) ,
428
433
attribute : self . attr_path . clone ( ) ,
429
434
reason : AttributeParseErrorReason :: ExpectedIdentifier ,
435
+ attr_style : self . attr_style ,
430
436
} )
431
437
}
432
438
@@ -439,6 +445,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
439
445
template : self . template . clone ( ) ,
440
446
attribute : self . attr_path . clone ( ) ,
441
447
reason : AttributeParseErrorReason :: ExpectedNameValue ( name) ,
448
+ attr_style : self . attr_style ,
442
449
} )
443
450
}
444
451
@@ -450,6 +457,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
450
457
template : self . template . clone ( ) ,
451
458
attribute : self . attr_path . clone ( ) ,
452
459
reason : AttributeParseErrorReason :: DuplicateKey ( key) ,
460
+ attr_style : self . attr_style ,
453
461
} )
454
462
}
455
463
@@ -462,6 +470,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
462
470
template : self . template . clone ( ) ,
463
471
attribute : self . attr_path . clone ( ) ,
464
472
reason : AttributeParseErrorReason :: UnexpectedLiteral ,
473
+ attr_style : self . attr_style ,
465
474
} )
466
475
}
467
476
@@ -472,6 +481,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
472
481
template : self . template . clone ( ) ,
473
482
attribute : self . attr_path . clone ( ) ,
474
483
reason : AttributeParseErrorReason :: ExpectedSingleArgument ,
484
+ attr_style : self . attr_style ,
475
485
} )
476
486
}
477
487
@@ -482,6 +492,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
482
492
template : self . template . clone ( ) ,
483
493
attribute : self . attr_path . clone ( ) ,
484
494
reason : AttributeParseErrorReason :: ExpectedAtLeastOneArgument ,
495
+ attr_style : self . attr_style ,
485
496
} )
486
497
}
487
498
@@ -500,6 +511,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
500
511
strings : false ,
501
512
list : false ,
502
513
} ,
514
+ attr_style : self . attr_style ,
503
515
} )
504
516
}
505
517
@@ -518,6 +530,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
518
530
strings : false ,
519
531
list : true ,
520
532
} ,
533
+ attr_style : self . attr_style ,
521
534
} )
522
535
}
523
536
@@ -536,6 +549,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
536
549
strings : true ,
537
550
list : false ,
538
551
} ,
552
+ attr_style : self . attr_style ,
539
553
} )
540
554
}
541
555
@@ -735,6 +749,7 @@ impl<'sess> AttributeParser<'sess, Early> {
735
749
} ,
736
750
} ,
737
751
attr_span : attr. span ,
752
+ attr_style : attr. style ,
738
753
template,
739
754
attr_path : path. get_attribute_path ( ) ,
740
755
} ;
@@ -844,6 +859,7 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
844
859
emit_lint : & mut emit_lint,
845
860
} ,
846
861
attr_span : lower_span ( attr. span ) ,
862
+ attr_style : attr. style ,
847
863
template : & accept. template ,
848
864
attr_path : path. get_attribute_path ( ) ,
849
865
} ;
0 commit comments