document why it is important to early return on ExpectedStringLiteral

This commit is contained in:
Sasha Pourcelot
2026-03-29 10:03:53 +00:00
parent fe4e53ebf2
commit bb40df6e56
@@ -687,13 +687,15 @@ fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
AttributeParseErrorReason::ExpectedStringLiteral { byte_string } => {
if let Some(start_point_span) = byte_string {
diag.span_suggestion(
start_point_span,
*start_point_span,
"consider removing the prefix",
"",
Applicability::MaybeIncorrect,
);
diag.note("expected a normal string literal, not a byte string literal");
// Avoid emitting an "attribute must be of the form" suggestion, as the
// attribute is likely to be well-formed already.
return diag;
} else {
diag.span_label(self.span, "expected a string literal here");