@@ -595,6 +595,23 @@ pub(crate) struct AttributeParseError<'a> {
595595}
596596
597597impl < ' a > AttributeParseError < ' a > {
598+ fn render_expected_string_literal < G > ( & self , diag : & mut Diag < ' _ , G > , byte_string : Option < Span > )
599+ where
600+ G : EmissionGuarantee ,
601+ {
602+ if let Some ( start_point_span) = byte_string {
603+ diag. span_suggestion (
604+ start_point_span,
605+ "consider removing the prefix" ,
606+ "" ,
607+ Applicability :: MaybeIncorrect ,
608+ ) ;
609+ diag. note ( "expected a normal string literal, not a byte string literal" ) ;
610+ } else {
611+ diag. span_label ( self . span , "expected a string literal here" ) ;
612+ }
613+ }
614+
598615 fn render_expected_specific_argument < G > (
599616 & self ,
600617 diag : & mut Diag < ' _ , G > ,
@@ -685,19 +702,7 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AttributeParseError<'_> {
685702 diag. code ( E0539 ) ;
686703 match & self . reason {
687704 AttributeParseErrorReason :: ExpectedStringLiteral { byte_string } => {
688- if let Some ( start_point_span) = byte_string {
689- diag. span_suggestion (
690- start_point_span,
691- "consider removing the prefix" ,
692- "" ,
693- Applicability :: MaybeIncorrect ,
694- ) ;
695- diag. note ( "expected a normal string literal, not a byte string literal" ) ;
696-
697- return diag;
698- } else {
699- diag. span_label ( self . span , "expected a string literal here" ) ;
700- }
705+ self . render_expected_string_literal ( & mut diag, * byte_string) ;
701706 }
702707 AttributeParseErrorReason :: ExpectedFilenameLiteral => {
703708 diag. span_label ( self . span , "expected a filename string literal here" ) ;
0 commit comments