Change lint_dropping_copy_types to use UseLetUnderscoreIgnoreSuggestion as suggestion.
This commit is contained in:
parent
ac736d6d88
commit
9d1ed80a8a
@ -232,8 +232,6 @@ lint_drop_trait_constraints =
|
||||
|
||||
lint_dropping_copy_types = calls to `std::mem::drop` with a value that implements `Copy` does nothing
|
||||
.label = argument has type `{$arg_ty}`
|
||||
.note = use `let _ = ...` to ignore the expression or result
|
||||
.suggestion = use `let _ = ...` to ignore the expression or result
|
||||
|
||||
lint_dropping_references = calls to `std::mem::drop` with a reference instead of an owned value does nothing
|
||||
.label = argument has type `{$arg_ty}`
|
||||
|
@ -5,9 +5,8 @@ use rustc_span::sym;
|
||||
|
||||
use crate::{
|
||||
lints::{
|
||||
DropCopyDiag, DropCopySuggestion, DropRefDiag, ForgetCopyDiag, ForgetRefDiag,
|
||||
UndroppedManuallyDropsDiag, UndroppedManuallyDropsSuggestion,
|
||||
UseLetUnderscoreIgnoreSuggestion,
|
||||
DropCopyDiag, DropRefDiag, ForgetCopyDiag, ForgetRefDiag, UndroppedManuallyDropsDiag,
|
||||
UndroppedManuallyDropsSuggestion, UseLetUnderscoreIgnoreSuggestion,
|
||||
},
|
||||
LateContext, LateLintPass, LintContext,
|
||||
};
|
||||
@ -183,23 +182,14 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless {
|
||||
);
|
||||
}
|
||||
sym::mem_drop if is_copy && !drop_is_single_call_in_arm => {
|
||||
let sugg = if let Some((_, node)) = cx.tcx.hir().parent_iter(expr.hir_id).nth(0)
|
||||
&& let Node::Stmt(stmt) = node
|
||||
&& let StmtKind::Semi(e) = stmt.kind
|
||||
&& e.hir_id == expr.hir_id
|
||||
{
|
||||
DropCopySuggestion::Suggestion {
|
||||
start_span: expr.span.shrink_to_lo().until(arg.span),
|
||||
end_span: arg.span.shrink_to_hi().until(expr.span.shrink_to_hi()),
|
||||
}
|
||||
} else {
|
||||
DropCopySuggestion::Note
|
||||
};
|
||||
|
||||
cx.emit_span_lint(
|
||||
DROPPING_COPY_TYPES,
|
||||
expr.span,
|
||||
DropCopyDiag { arg_ty, label: arg.span, sugg },
|
||||
DropCopyDiag {
|
||||
arg_ty,
|
||||
label: arg.span,
|
||||
sugg: let_underscore_ignore_sugg(),
|
||||
},
|
||||
);
|
||||
}
|
||||
sym::mem_forget if is_copy => {
|
||||
|
@ -691,20 +691,7 @@ pub struct DropCopyDiag<'a> {
|
||||
#[label]
|
||||
pub label: Span,
|
||||
#[subdiagnostic]
|
||||
pub sugg: DropCopySuggestion,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
pub enum DropCopySuggestion {
|
||||
#[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,
|
||||
},
|
||||
pub sugg: UseLetUnderscoreIgnoreSuggestion,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user