1
Fork 0

Use label instead of note to be more consistent with other lints

This commit is contained in:
Urgau 2023-04-10 11:55:37 +02:00
parent 77773ad002
commit 457fa953a2
7 changed files with 133 additions and 283 deletions

View file

@ -123,16 +123,16 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless {
let drop_is_single_call_in_arm = is_single_call_in_arm(cx, arg, expr);
match fn_name {
sym::mem_drop if arg_ty.is_ref() && !drop_is_single_call_in_arm => {
cx.emit_spanned_lint(DROP_REF, expr.span, DropRefDiag { arg_ty, note: arg.span });
cx.emit_spanned_lint(DROP_REF, expr.span, DropRefDiag { arg_ty, label: arg.span });
},
sym::mem_forget if arg_ty.is_ref() => {
cx.emit_spanned_lint(FORGET_REF, expr.span, ForgetRefDiag { arg_ty, note: arg.span });
cx.emit_spanned_lint(FORGET_REF, expr.span, ForgetRefDiag { arg_ty, label: arg.span });
},
sym::mem_drop if is_copy && !drop_is_single_call_in_arm => {
cx.emit_spanned_lint(DROP_COPY, expr.span, DropCopyDiag { arg_ty, note: arg.span });
cx.emit_spanned_lint(DROP_COPY, expr.span, DropCopyDiag { arg_ty, label: arg.span });
}
sym::mem_forget if is_copy => {
cx.emit_spanned_lint(FORGET_COPY, expr.span, ForgetCopyDiag { arg_ty, note: arg.span });
cx.emit_spanned_lint(FORGET_COPY, expr.span, ForgetCopyDiag { arg_ty, label: arg.span });
}
_ => return,
};

View file

@ -667,32 +667,32 @@ pub struct ForLoopsOverFalliblesSuggestion<'a> {
#[diag(lint_drop_ref)]
pub struct DropRefDiag<'a> {
pub arg_ty: Ty<'a>,
#[note]
pub note: Span,
#[label]
pub label: Span,
}
#[derive(LintDiagnostic)]
#[diag(lint_drop_copy)]
pub struct DropCopyDiag<'a> {
pub arg_ty: Ty<'a>,
#[note]
pub note: Span,
#[label]
pub label: Span,
}
#[derive(LintDiagnostic)]
#[diag(lint_forget_ref)]
pub struct ForgetRefDiag<'a> {
pub arg_ty: Ty<'a>,
#[note]
pub note: Span,
#[label]
pub label: Span,
}
#[derive(LintDiagnostic)]
#[diag(lint_forget_copy)]
pub struct ForgetCopyDiag<'a> {
pub arg_ty: Ty<'a>,
#[note]
pub note: Span,
#[label]
pub label: Span,
}
// hidden_unicode_codepoints.rs