@@ -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 ;
@@ -304,6 +304,7 @@ pub struct AcceptContext<'f, 'sess, S: Stage> {
304
304
/// The span of the attribute currently being parsed
305
305
pub ( crate ) attr_span : Span ,
306
306
307
+ pub ( crate ) attr_style : AttrStyle ,
307
308
/// The expected structure of the attribute.
308
309
///
309
310
/// 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> {
385
386
i. kind . is_bytestr ( ) . then ( || self . sess ( ) . source_map ( ) . start_point ( i. span ) )
386
387
} ) ,
387
388
} ,
389
+ attr_style : self . attr_style ,
388
390
} )
389
391
}
390
392
@@ -395,6 +397,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
395
397
template : self . template . clone ( ) ,
396
398
attribute : self . attr_path . clone ( ) ,
397
399
reason : AttributeParseErrorReason :: ExpectedIntegerLiteral ,
400
+ attr_style : self . attr_style ,
398
401
} )
399
402
}
400
403
@@ -405,6 +408,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
405
408
template : self . template . clone ( ) ,
406
409
attribute : self . attr_path . clone ( ) ,
407
410
reason : AttributeParseErrorReason :: ExpectedList ,
411
+ attr_style : self . attr_style ,
408
412
} )
409
413
}
410
414
@@ -415,6 +419,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
415
419
template : self . template . clone ( ) ,
416
420
attribute : self . attr_path . clone ( ) ,
417
421
reason : AttributeParseErrorReason :: ExpectedNoArgs ,
422
+ attr_style : self . attr_style ,
418
423
} )
419
424
}
420
425
@@ -426,6 +431,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
426
431
template : self . template . clone ( ) ,
427
432
attribute : self . attr_path . clone ( ) ,
428
433
reason : AttributeParseErrorReason :: ExpectedIdentifier ,
434
+ attr_style : self . attr_style ,
429
435
} )
430
436
}
431
437
@@ -438,6 +444,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
438
444
template : self . template . clone ( ) ,
439
445
attribute : self . attr_path . clone ( ) ,
440
446
reason : AttributeParseErrorReason :: ExpectedNameValue ( name) ,
447
+ attr_style : self . attr_style ,
441
448
} )
442
449
}
443
450
@@ -449,6 +456,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
449
456
template : self . template . clone ( ) ,
450
457
attribute : self . attr_path . clone ( ) ,
451
458
reason : AttributeParseErrorReason :: DuplicateKey ( key) ,
459
+ attr_style : self . attr_style ,
452
460
} )
453
461
}
454
462
@@ -461,6 +469,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
461
469
template : self . template . clone ( ) ,
462
470
attribute : self . attr_path . clone ( ) ,
463
471
reason : AttributeParseErrorReason :: UnexpectedLiteral ,
472
+ attr_style : self . attr_style ,
464
473
} )
465
474
}
466
475
@@ -471,6 +480,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
471
480
template : self . template . clone ( ) ,
472
481
attribute : self . attr_path . clone ( ) ,
473
482
reason : AttributeParseErrorReason :: ExpectedSingleArgument ,
483
+ attr_style : self . attr_style ,
474
484
} )
475
485
}
476
486
@@ -481,6 +491,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
481
491
template : self . template . clone ( ) ,
482
492
attribute : self . attr_path . clone ( ) ,
483
493
reason : AttributeParseErrorReason :: ExpectedAtLeastOneArgument ,
494
+ attr_style : self . attr_style ,
484
495
} )
485
496
}
486
497
@@ -499,6 +510,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
499
510
strings : false ,
500
511
list : false ,
501
512
} ,
513
+ attr_style : self . attr_style ,
502
514
} )
503
515
}
504
516
@@ -517,6 +529,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
517
529
strings : false ,
518
530
list : true ,
519
531
} ,
532
+ attr_style : self . attr_style ,
520
533
} )
521
534
}
522
535
@@ -535,6 +548,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
535
548
strings : true ,
536
549
list : false ,
537
550
} ,
551
+ attr_style : self . attr_style ,
538
552
} )
539
553
}
540
554
@@ -734,6 +748,7 @@ impl<'sess> AttributeParser<'sess, Early> {
734
748
} ,
735
749
} ,
736
750
attr_span : attr. span ,
751
+ attr_style : attr. style ,
737
752
template,
738
753
attr_path : path. get_attribute_path ( ) ,
739
754
} ;
@@ -843,6 +858,7 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
843
858
emit_lint : & mut emit_lint,
844
859
} ,
845
860
attr_span : lower_span ( attr. span ) ,
861
+ attr_style : attr. style ,
846
862
template : & accept. template ,
847
863
attr_path : path. get_attribute_path ( ) ,
848
864
} ;
0 commit comments