diff options
| author | Jacherr <jwc2002@outlook.com> | 2023-11-15 00:14:38 +0000 |
|---|---|---|
| committer | Jacherr <jwc2002@outlook.com> | 2023-11-15 00:14:38 +0000 |
| commit | a86a57079dcbd5144343a4dbc3dd318702a12ea5 (patch) | |
| tree | 51d487b5ce87389e912b0fd7027e4dd4b611a831 | |
| parent | 0c42e451d643d54347aa47d7bc6c731896fe5fde (diff) | |
| download | rust-a86a57079dcbd5144343a4dbc3dd318702a12ea5.tar.gz rust-a86a57079dcbd5144343a4dbc3dd318702a12ea5.zip | |
replace lint with `span_lint_and_then`
| -rw-r--r-- | clippy_lints/src/casts/cast_possible_wrap.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/clippy_lints/src/casts/cast_possible_wrap.rs b/clippy_lints/src/casts/cast_possible_wrap.rs index ffa571abb39..2ddb0f00ecd 100644 --- a/clippy_lints/src/casts/cast_possible_wrap.rs +++ b/clippy_lints/src/casts/cast_possible_wrap.rs @@ -1,5 +1,6 @@ +use clippy_utils::diagnostics::span_lint_and_then; use rustc_hir::Expr; -use rustc_lint::{LateContext, LintContext}; +use rustc_lint::LateContext; use rustc_middle::ty::Ty; use super::{utils, CAST_POSSIBLE_WRAP}; @@ -78,13 +79,11 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, ca ), }; - cx.struct_span_lint(CAST_POSSIBLE_WRAP, expr.span, message, |diag| { + span_lint_and_then(cx, CAST_POSSIBLE_WRAP, expr.span, &message, |diag| { if let EmitState::LintOnPtrSize(16) = should_lint { diag - .note("`usize` and `isize` may be as small as 16 bits on some platforms") - .note("for more information see https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types") - } else { - diag - } + .note("`usize` and `isize` may be as small as 16 bits on some platforms") + .note("for more information see https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types"); + }; }); } |
