1
Fork 0

Let lint_dropping_references give the suggestion if possible.

This commit is contained in:
surechen 2024-05-25 09:55:49 +08:00
parent 5870f1ccbb
commit ca68c93135
7 changed files with 261 additions and 13 deletions

View file

@ -656,14 +656,28 @@ pub struct ForLoopsOverFalliblesSuggestion<'a> {
pub end_span: Span,
}
#[derive(Subdiagnostic)]
pub enum IgnoreDropSuggestion {
#[note(lint_note)]
Note,
#[multipart_suggestion(lint_suggestion, style = "verbose", applicability = "maybe-incorrect")]
Suggestion {
#[suggestion_part(code = "let _ = ")]
start_span: Span,
#[suggestion_part(code = "")]
end_span: Span,
},
}
// drop_forget_useless.rs
#[derive(LintDiagnostic)]
#[diag(lint_dropping_references)]
#[note]
pub struct DropRefDiag<'a> {
pub arg_ty: Ty<'a>,
#[label]
pub label: Span,
#[subdiagnostic]
pub sugg: IgnoreDropSuggestion,
}
#[derive(LintDiagnostic)]