@@ -5,7 +5,7 @@ use std::sync::LazyLock;
5
5
6
6
use itertools:: Itertools ;
7
7
use private:: Sealed ;
8
- use rustc_ast:: { self as ast, LitKind , MetaItemLit , NodeId } ;
8
+ use rustc_ast:: { self as ast, AttrStyle , LitKind , MetaItemLit , NodeId } ;
9
9
use rustc_errors:: { DiagCtxtHandle , Diagnostic } ;
10
10
use rustc_feature:: { AttributeTemplate , Features } ;
11
11
use rustc_hir:: attrs:: AttributeKind ;
@@ -315,6 +315,7 @@ pub struct AcceptContext<'f, 'sess, S: Stage> {
315
315
/// The span of the attribute currently being parsed
316
316
pub ( crate ) attr_span : Span ,
317
317
318
+ pub ( crate ) attr_style : AttrStyle ,
318
319
/// The expected structure of the attribute.
319
320
///
320
321
/// Used in reporting errors to give a hint to users what the attribute *should* look like.
@@ -396,6 +397,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
396
397
i. kind . is_bytestr ( ) . then ( || self . sess ( ) . source_map ( ) . start_point ( i. span ) )
397
398
} ) ,
398
399
} ,
400
+ attr_style : self . attr_style ,
399
401
} )
400
402
}
401
403
@@ -406,6 +408,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
406
408
template : self . template . clone ( ) ,
407
409
attribute : self . attr_path . clone ( ) ,
408
410
reason : AttributeParseErrorReason :: ExpectedIntegerLiteral ,
411
+ attr_style : self . attr_style ,
409
412
} )
410
413
}
411
414
@@ -416,6 +419,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
416
419
template : self . template . clone ( ) ,
417
420
attribute : self . attr_path . clone ( ) ,
418
421
reason : AttributeParseErrorReason :: ExpectedList ,
422
+ attr_style : self . attr_style ,
419
423
} )
420
424
}
421
425
@@ -426,6 +430,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
426
430
template : self . template . clone ( ) ,
427
431
attribute : self . attr_path . clone ( ) ,
428
432
reason : AttributeParseErrorReason :: ExpectedNoArgs ,
433
+ attr_style : self . attr_style ,
429
434
} )
430
435
}
431
436
@@ -437,6 +442,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
437
442
template : self . template . clone ( ) ,
438
443
attribute : self . attr_path . clone ( ) ,
439
444
reason : AttributeParseErrorReason :: ExpectedIdentifier ,
445
+ attr_style : self . attr_style ,
440
446
} )
441
447
}
442
448
@@ -449,6 +455,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
449
455
template : self . template . clone ( ) ,
450
456
attribute : self . attr_path . clone ( ) ,
451
457
reason : AttributeParseErrorReason :: ExpectedNameValue ( name) ,
458
+ attr_style : self . attr_style ,
452
459
} )
453
460
}
454
461
@@ -460,6 +467,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
460
467
template : self . template . clone ( ) ,
461
468
attribute : self . attr_path . clone ( ) ,
462
469
reason : AttributeParseErrorReason :: DuplicateKey ( key) ,
470
+ attr_style : self . attr_style ,
463
471
} )
464
472
}
465
473
@@ -472,6 +480,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
472
480
template : self . template . clone ( ) ,
473
481
attribute : self . attr_path . clone ( ) ,
474
482
reason : AttributeParseErrorReason :: UnexpectedLiteral ,
483
+ attr_style : self . attr_style ,
475
484
} )
476
485
}
477
486
@@ -482,6 +491,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
482
491
template : self . template . clone ( ) ,
483
492
attribute : self . attr_path . clone ( ) ,
484
493
reason : AttributeParseErrorReason :: ExpectedSingleArgument ,
494
+ attr_style : self . attr_style ,
485
495
} )
486
496
}
487
497
@@ -492,6 +502,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
492
502
template : self . template . clone ( ) ,
493
503
attribute : self . attr_path . clone ( ) ,
494
504
reason : AttributeParseErrorReason :: ExpectedAtLeastOneArgument ,
505
+ attr_style : self . attr_style ,
495
506
} )
496
507
}
497
508
@@ -510,6 +521,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
510
521
strings : false ,
511
522
list : false ,
512
523
} ,
524
+ attr_style : self . attr_style ,
513
525
} )
514
526
}
515
527
@@ -528,6 +540,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
528
540
strings : false ,
529
541
list : true ,
530
542
} ,
543
+ attr_style : self . attr_style ,
531
544
} )
532
545
}
533
546
@@ -546,6 +559,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
546
559
strings : true ,
547
560
list : false ,
548
561
} ,
562
+ attr_style : self . attr_style ,
549
563
} )
550
564
}
551
565
@@ -804,6 +818,7 @@ impl<'sess> AttributeParser<'sess, Early> {
804
818
} ,
805
819
} ,
806
820
attr_span : attr. span ,
821
+ attr_style : attr. style ,
807
822
template,
808
823
attr_path : path. get_attribute_path ( ) ,
809
824
} ;
@@ -914,6 +929,7 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
914
929
emit_lint : & mut emit_lint,
915
930
} ,
916
931
attr_span : lower_span ( attr. span ) ,
932
+ attr_style : attr. style ,
917
933
template : & accept. template ,
918
934
attr_path : path. get_attribute_path ( ) ,
919
935
} ;
0 commit comments