Add link to docs on malformed attributes

This commit is contained in:
Esteban Küber
2025-08-11 04:21:09 +00:00
parent 189f264926
commit 625143bac3
23 changed files with 344 additions and 87 deletions

View File

@@ -313,24 +313,27 @@ fn emit_malformed_attribute(
ILL_FORMED_ATTRIBUTE_INPUT,
span,
ast::CRATE_NODE_ID,
BuiltinLintDiag::IllFormedAttributeInput { suggestions: suggestions.clone() },
BuiltinLintDiag::IllFormedAttributeInput {
suggestions: suggestions.clone(),
docs: template.docs,
},
);
} else {
suggestions.sort();
psess
.dcx()
.struct_span_err(span, error_msg)
.with_span_suggestions(
span,
if suggestions.len() == 1 {
"must be of the form"
} else {
"the following are the possible correct uses"
},
suggestions,
Applicability::HasPlaceholders,
)
.emit();
let mut err = psess.dcx().struct_span_err(span, error_msg).with_span_suggestions(
span,
if suggestions.len() == 1 {
"must be of the form"
} else {
"the following are the possible correct uses"
},
suggestions,
Applicability::HasPlaceholders,
);
if let Some(link) = template.docs {
err.note(format!("for more information, visit <{link}>"));
}
err.emit();
}
}