1
Fork 0

Rollup merge of #133487 - pitaj:reserve-guarded-strings, r=fee1-dead

fix confusing diagnostic for reserved `##`

Closes #131615
This commit is contained in:
Guillaume Gomez 2024-11-28 12:06:04 +01:00 committed by GitHub
commit ca71c8fe5e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 141 additions and 107 deletions

View file

@ -176,8 +176,12 @@ pub(super) fn decorate_lint(sess: &Session, diagnostic: BuiltinLintDiag, diag: &
lints::RawPrefix { label: label_span, suggestion: label_span.shrink_to_hi() }
.decorate_lint(diag);
}
BuiltinLintDiag::ReservedString(suggestion) => {
lints::ReservedString { suggestion }.decorate_lint(diag);
BuiltinLintDiag::ReservedString { is_string, suggestion } => {
if is_string {
lints::ReservedString { suggestion }.decorate_lint(diag);
} else {
lints::ReservedMultihash { suggestion }.decorate_lint(diag);
}
}
BuiltinLintDiag::UnusedBuiltinAttribute { attr_name, macro_name, invoc_span } => {
lints::UnusedBuiltinAttribute { invoc_span, attr_name, macro_name }.decorate_lint(diag);

View file

@ -3059,3 +3059,10 @@ pub(crate) struct ReservedString {
#[suggestion(code = " ", applicability = "machine-applicable")]
pub suggestion: Span,
}
#[derive(LintDiagnostic)]
#[diag(lint_reserved_multihash)]
pub(crate) struct ReservedMultihash {
#[suggestion(code = " ", applicability = "machine-applicable")]
pub suggestion: Span,
}