@@ -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 ;
@@ -301,6 +301,7 @@ pub struct AcceptContext<'f, 'sess, S: Stage> {
301
301
/// The span of the attribute currently being parsed
302
302
pub ( crate ) attr_span : Span ,
303
303
304
+ pub ( crate ) attr_style : AttrStyle ,
304
305
/// The expected structure of the attribute.
305
306
///
306
307
/// Used in reporting errors to give a hint to users what the attribute *should* look like.
@@ -382,6 +383,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
382
383
i. kind . is_bytestr ( ) . then ( || self . sess ( ) . source_map ( ) . start_point ( i. span ) )
383
384
} ) ,
384
385
} ,
386
+ attr_style : self . attr_style ,
385
387
} )
386
388
}
387
389
@@ -392,6 +394,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
392
394
template : self . template . clone ( ) ,
393
395
attribute : self . attr_path . clone ( ) ,
394
396
reason : AttributeParseErrorReason :: ExpectedIntegerLiteral ,
397
+ attr_style : self . attr_style ,
395
398
} )
396
399
}
397
400
@@ -402,6 +405,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
402
405
template : self . template . clone ( ) ,
403
406
attribute : self . attr_path . clone ( ) ,
404
407
reason : AttributeParseErrorReason :: ExpectedList ,
408
+ attr_style : self . attr_style ,
405
409
} )
406
410
}
407
411
@@ -412,6 +416,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
412
416
template : self . template . clone ( ) ,
413
417
attribute : self . attr_path . clone ( ) ,
414
418
reason : AttributeParseErrorReason :: ExpectedNoArgs ,
419
+ attr_style : self . attr_style ,
415
420
} )
416
421
}
417
422
@@ -423,6 +428,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
423
428
template : self . template . clone ( ) ,
424
429
attribute : self . attr_path . clone ( ) ,
425
430
reason : AttributeParseErrorReason :: ExpectedIdentifier ,
431
+ attr_style : self . attr_style ,
426
432
} )
427
433
}
428
434
@@ -435,6 +441,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
435
441
template : self . template . clone ( ) ,
436
442
attribute : self . attr_path . clone ( ) ,
437
443
reason : AttributeParseErrorReason :: ExpectedNameValue ( name) ,
444
+ attr_style : self . attr_style ,
438
445
} )
439
446
}
440
447
@@ -446,6 +453,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
446
453
template : self . template . clone ( ) ,
447
454
attribute : self . attr_path . clone ( ) ,
448
455
reason : AttributeParseErrorReason :: DuplicateKey ( key) ,
456
+ attr_style : self . attr_style ,
449
457
} )
450
458
}
451
459
@@ -458,6 +466,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
458
466
template : self . template . clone ( ) ,
459
467
attribute : self . attr_path . clone ( ) ,
460
468
reason : AttributeParseErrorReason :: UnexpectedLiteral ,
469
+ attr_style : self . attr_style ,
461
470
} )
462
471
}
463
472
@@ -468,6 +477,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
468
477
template : self . template . clone ( ) ,
469
478
attribute : self . attr_path . clone ( ) ,
470
479
reason : AttributeParseErrorReason :: ExpectedSingleArgument ,
480
+ attr_style : self . attr_style ,
471
481
} )
472
482
}
473
483
@@ -478,6 +488,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
478
488
template : self . template . clone ( ) ,
479
489
attribute : self . attr_path . clone ( ) ,
480
490
reason : AttributeParseErrorReason :: ExpectedAtLeastOneArgument ,
491
+ attr_style : self . attr_style ,
481
492
} )
482
493
}
483
494
@@ -496,6 +507,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
496
507
strings : false ,
497
508
list : false ,
498
509
} ,
510
+ attr_style : self . attr_style ,
499
511
} )
500
512
}
501
513
@@ -514,6 +526,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
514
526
strings : false ,
515
527
list : true ,
516
528
} ,
529
+ attr_style : self . attr_style ,
517
530
} )
518
531
}
519
532
@@ -532,6 +545,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
532
545
strings : true ,
533
546
list : false ,
534
547
} ,
548
+ attr_style : self . attr_style ,
535
549
} )
536
550
}
537
551
@@ -731,6 +745,7 @@ impl<'sess> AttributeParser<'sess, Early> {
731
745
} ,
732
746
} ,
733
747
attr_span : attr. span ,
748
+ attr_style : attr. style ,
734
749
template,
735
750
attr_path : path. get_attribute_path ( ) ,
736
751
} ;
@@ -840,6 +855,7 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
840
855
emit_lint : & mut emit_lint,
841
856
} ,
842
857
attr_span : lower_span ( attr. span ) ,
858
+ attr_style : attr. style ,
843
859
template : & accept. template ,
844
860
attr_path : path. get_attribute_path ( ) ,
845
861
} ;
0 commit comments