Skip to content

Commit ea7672a

Browse files
committed
use span_lint_and_sugg
1 parent 043346b commit ea7672a

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

clippy_lints/src/transmute/transmute_int_to_non_zero.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::TRANSMUTE_INT_TO_NON_ZERO;
2-
use clippy_utils::diagnostics::span_lint_and_then;
2+
use clippy_utils::diagnostics::span_lint_and_sugg;
33
use clippy_utils::sugg;
44
use rustc_errors::Applicability;
55
use rustc_hir::Expr;
@@ -22,20 +22,15 @@ pub(super) fn check<'tcx>(
2222
&& let int_ty = substs.type_at(0)
2323
&& from_ty == int_ty
2424
{
25-
span_lint_and_then(
25+
let arg = sugg::Sugg::hir(cx, arg, "..");
26+
span_lint_and_sugg(
2627
cx,
2728
TRANSMUTE_INT_TO_NON_ZERO,
2829
e.span,
2930
format!("transmute from a `{from_ty}` to a `{}<{int_ty}>`", sym::NonZero),
30-
|diag| {
31-
let arg = sugg::Sugg::hir(cx, arg, "..");
32-
diag.span_suggestion(
33-
e.span,
34-
"consider using",
35-
format!("{}::{}({arg})", sym::NonZero, sym::new_unchecked),
36-
Applicability::Unspecified,
37-
);
38-
},
31+
"consider using",
32+
format!("{}::{}({arg})", sym::NonZero, sym::new_unchecked),
33+
Applicability::Unspecified,
3934
);
4035
true
4136
} else {

0 commit comments

Comments
 (0)