@@ -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 ;
@@ -313,6 +313,7 @@ pub struct AcceptContext<'f, 'sess, S: Stage> {
313
313
/// The span of the attribute currently being parsed
314
314
pub ( crate ) attr_span : Span ,
315
315
316
+ pub ( crate ) attr_style : AttrStyle ,
316
317
/// The expected structure of the attribute.
317
318
///
318
319
/// Used in reporting errors to give a hint to users what the attribute *should* look like.
@@ -394,6 +395,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
394
395
i. kind . is_bytestr ( ) . then ( || self . sess ( ) . source_map ( ) . start_point ( i. span ) )
395
396
} ) ,
396
397
} ,
398
+ attr_style : self . attr_style ,
397
399
} )
398
400
}
399
401
@@ -404,6 +406,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
404
406
template : self . template . clone ( ) ,
405
407
attribute : self . attr_path . clone ( ) ,
406
408
reason : AttributeParseErrorReason :: ExpectedIntegerLiteral ,
409
+ attr_style : self . attr_style ,
407
410
} )
408
411
}
409
412
@@ -414,6 +417,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
414
417
template : self . template . clone ( ) ,
415
418
attribute : self . attr_path . clone ( ) ,
416
419
reason : AttributeParseErrorReason :: ExpectedList ,
420
+ attr_style : self . attr_style ,
417
421
} )
418
422
}
419
423
@@ -424,6 +428,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
424
428
template : self . template . clone ( ) ,
425
429
attribute : self . attr_path . clone ( ) ,
426
430
reason : AttributeParseErrorReason :: ExpectedNoArgs ,
431
+ attr_style : self . attr_style ,
427
432
} )
428
433
}
429
434
@@ -435,6 +440,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
435
440
template : self . template . clone ( ) ,
436
441
attribute : self . attr_path . clone ( ) ,
437
442
reason : AttributeParseErrorReason :: ExpectedIdentifier ,
443
+ attr_style : self . attr_style ,
438
444
} )
439
445
}
440
446
@@ -447,6 +453,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
447
453
template : self . template . clone ( ) ,
448
454
attribute : self . attr_path . clone ( ) ,
449
455
reason : AttributeParseErrorReason :: ExpectedNameValue ( name) ,
456
+ attr_style : self . attr_style ,
450
457
} )
451
458
}
452
459
@@ -458,6 +465,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
458
465
template : self . template . clone ( ) ,
459
466
attribute : self . attr_path . clone ( ) ,
460
467
reason : AttributeParseErrorReason :: DuplicateKey ( key) ,
468
+ attr_style : self . attr_style ,
461
469
} )
462
470
}
463
471
@@ -470,6 +478,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
470
478
template : self . template . clone ( ) ,
471
479
attribute : self . attr_path . clone ( ) ,
472
480
reason : AttributeParseErrorReason :: UnexpectedLiteral ,
481
+ attr_style : self . attr_style ,
473
482
} )
474
483
}
475
484
@@ -480,6 +489,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
480
489
template : self . template . clone ( ) ,
481
490
attribute : self . attr_path . clone ( ) ,
482
491
reason : AttributeParseErrorReason :: ExpectedSingleArgument ,
492
+ attr_style : self . attr_style ,
483
493
} )
484
494
}
485
495
@@ -490,6 +500,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
490
500
template : self . template . clone ( ) ,
491
501
attribute : self . attr_path . clone ( ) ,
492
502
reason : AttributeParseErrorReason :: ExpectedAtLeastOneArgument ,
503
+ attr_style : self . attr_style ,
493
504
} )
494
505
}
495
506
@@ -508,6 +519,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
508
519
strings : false ,
509
520
list : false ,
510
521
} ,
522
+ attr_style : self . attr_style ,
511
523
} )
512
524
}
513
525
@@ -526,6 +538,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
526
538
strings : false ,
527
539
list : true ,
528
540
} ,
541
+ attr_style : self . attr_style ,
529
542
} )
530
543
}
531
544
@@ -544,6 +557,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
544
557
strings : true ,
545
558
list : false ,
546
559
} ,
560
+ attr_style : self . attr_style ,
547
561
} )
548
562
}
549
563
@@ -802,6 +816,7 @@ impl<'sess> AttributeParser<'sess, Early> {
802
816
} ,
803
817
} ,
804
818
attr_span : attr. span ,
819
+ attr_style : attr. style ,
805
820
template,
806
821
attr_path : path. get_attribute_path ( ) ,
807
822
} ;
@@ -912,6 +927,7 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
912
927
emit_lint : & mut emit_lint,
913
928
} ,
914
929
attr_span : lower_span ( attr. span ) ,
930
+ attr_style : attr. style ,
915
931
template : & accept. template ,
916
932
attr_path : path. get_attribute_path ( ) ,
917
933
} ;
0 commit comments