@@ -16,8 +16,6 @@ pub(crate) enum UnsupportedLiteralReason {
16
16
Generic ,
17
17
CfgString ,
18
18
CfgBoolean ,
19
- DeprecatedString ,
20
- DeprecatedKvPair ,
21
19
}
22
20
23
21
#[ derive( Diagnostic ) ]
@@ -190,6 +188,7 @@ pub(crate) struct InvalidReprHintNoValue {
190
188
}
191
189
192
190
/// Error code: E0565
191
+ // FIXME(jdonszelmann): slowly phased out
193
192
pub ( crate ) struct UnsupportedLiteral {
194
193
pub span : Span ,
195
194
pub reason : UnsupportedLiteralReason ,
@@ -212,12 +211,6 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for UnsupportedLiteral {
212
211
UnsupportedLiteralReason :: CfgBoolean => {
213
212
fluent:: attr_parsing_unsupported_literal_cfg_boolean
214
213
}
215
- UnsupportedLiteralReason :: DeprecatedString => {
216
- fluent:: attr_parsing_unsupported_literal_deprecated_string
217
- }
218
- UnsupportedLiteralReason :: DeprecatedKvPair => {
219
- fluent:: attr_parsing_unsupported_literal_deprecated_kv_pair
220
- }
221
214
} ,
222
215
) ;
223
216
diag. span ( self . span ) ;
@@ -473,9 +466,10 @@ pub(crate) struct UnrecognizedReprHint {
473
466
}
474
467
475
468
pub ( crate ) enum AttributeParseErrorReason {
476
- ExpectedStringLiteral ,
469
+ ExpectedStringLiteral { byte_string : Option < Span > } ,
477
470
ExpectedSingleArgument ,
478
471
ExpectedList ,
472
+ UnexpectedLiteral ,
479
473
ExpectedNameValue ( Option < Symbol > ) ,
480
474
DuplicateKey ( Symbol ) ,
481
475
ExpectedSpecificArgument { possibilities : Vec < & ' static str > , strings : bool } ,
@@ -497,27 +491,44 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AttributeParseError {
497
491
diag. span ( self . attr_span ) ;
498
492
diag. code ( E0539 ) ;
499
493
match self . reason {
500
- AttributeParseErrorReason :: ExpectedStringLiteral => {
501
- diag. span_note ( self . span , "expected a string literal here" ) ;
494
+ AttributeParseErrorReason :: ExpectedStringLiteral { byte_string } => {
495
+ if let Some ( start_point_span) = byte_string {
496
+ diag. span_suggestion (
497
+ start_point_span,
498
+ fluent:: attr_parsing_unsupported_literal_suggestion,
499
+ "" ,
500
+ Applicability :: MaybeIncorrect ,
501
+ ) ;
502
+ diag. note ( "expected a normal string literal, not a byte string literal" ) ;
503
+
504
+ return diag;
505
+ } else {
506
+ diag. span_label ( self . span , "expected a string literal here" ) ;
507
+ }
502
508
}
503
509
AttributeParseErrorReason :: ExpectedSingleArgument => {
504
- diag. span_note ( self . span , "expected a single argument here" ) ;
510
+ diag. span_label ( self . span , "expected a single argument here" ) ;
511
+ diag. code ( E0540 ) ;
505
512
}
506
513
AttributeParseErrorReason :: ExpectedList => {
507
- diag. span_note ( self . span , "expected this to be a list" ) ;
514
+ diag. span_label ( self . span , "expected this to be a list" ) ;
508
515
}
509
516
AttributeParseErrorReason :: DuplicateKey ( key) => {
510
- diag. span_note ( self . span , format ! ( "found `{key}` used as a key more than once" ) ) ;
517
+ diag. span_label ( self . span , format ! ( "found `{key}` used as a key more than once" ) ) ;
511
518
diag. code ( E0538 ) ;
512
519
}
520
+ AttributeParseErrorReason :: UnexpectedLiteral => {
521
+ diag. span_label ( self . span , format ! ( "didn't expect a literal here" ) ) ;
522
+ diag. code ( E0565 ) ;
523
+ }
513
524
AttributeParseErrorReason :: ExpectedNameValue ( None ) => {
514
- diag. span_note (
525
+ diag. span_label (
515
526
self . span ,
516
527
format ! ( "expected this to be of the form `{name} = \" ...\" `" ) ,
517
528
) ;
518
529
}
519
530
AttributeParseErrorReason :: ExpectedNameValue ( Some ( name) ) => {
520
- diag. span_note (
531
+ diag. span_label (
521
532
self . span ,
522
533
format ! ( "expected this to be of the form `{name} = \" ...\" `" ) ,
523
534
) ;
@@ -527,13 +538,13 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AttributeParseError {
527
538
match possibilities. as_slice ( ) {
528
539
& [ ] => { }
529
540
& [ x] => {
530
- diag. span_note (
541
+ diag. span_label (
531
542
self . span ,
532
543
format ! ( "the only valid argument here is {quote}{x}{quote}" ) ,
533
544
) ;
534
545
}
535
546
[ first, second] => {
536
- diag. span_note ( self . span , format ! ( "valid arguments are {quote}{first}{quote} or {quote}{second}{quote}" ) ) ;
547
+ diag. span_label ( self . span , format ! ( "valid arguments are {quote}{first}{quote} or {quote}{second}{quote}" ) ) ;
537
548
}
538
549
[ first @ .., second_to_last, last] => {
539
550
let mut res = String :: new ( ) ;
@@ -544,7 +555,7 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AttributeParseError {
544
555
"{quote}{second_to_last}{quote} or {quote}{last}{quote}"
545
556
) ) ;
546
557
547
- diag. span_note ( self . span , format ! ( "valid arguments are {res}" ) ) ;
558
+ diag. span_label ( self . span , format ! ( "valid arguments are {res}" ) ) ;
548
559
}
549
560
}
550
561
}
0 commit comments