Simplify clippy
lint.
This commit is contained in:
parent
10913d27a1
commit
7ad336f3a8
@ -257,7 +257,7 @@ declare_clippy_lint! {
|
|||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// ### What it does
|
/// ### What it does
|
||||||
/// Checks for transmutes from integers to `NonZero*` types, and suggests their `new_unchecked`
|
/// Checks for transmutes from `T` to `NonZero<T>`, and suggests the `new_unchecked`
|
||||||
/// method instead.
|
/// method instead.
|
||||||
///
|
///
|
||||||
/// ### Why is this bad?
|
/// ### Why is this bad?
|
||||||
@ -266,13 +266,13 @@ declare_clippy_lint! {
|
|||||||
///
|
///
|
||||||
/// ### Example
|
/// ### Example
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// # use core::num::NonZeroU32;
|
/// # use core::num::NonZero;
|
||||||
/// let _non_zero: NonZeroU32 = unsafe { std::mem::transmute(123) };
|
/// let _: NonZero<u32> = unsafe { std::mem::transmute(123) };
|
||||||
/// ```
|
/// ```
|
||||||
/// Use instead:
|
/// Use instead:
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// # use core::num::NonZeroU32;
|
/// # use core::num::NonZero;
|
||||||
/// let _non_zero = unsafe { NonZeroU32::new_unchecked(123) };
|
/// let _: NonZero<u32> = unsafe { NonZero::new_unchecked(123) };
|
||||||
/// ```
|
/// ```
|
||||||
#[clippy::version = "1.69.0"]
|
#[clippy::version = "1.69.0"]
|
||||||
pub TRANSMUTE_INT_TO_NON_ZERO,
|
pub TRANSMUTE_INT_TO_NON_ZERO,
|
||||||
|
@ -26,45 +26,22 @@ pub(super) fn check<'tcx>(
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: This can be simplified once `NonZero<T>` is stable.
|
let int_ty = substs.type_at(0);
|
||||||
let coercible_types = [
|
if from_ty != int_ty {
|
||||||
("NonZeroU8", tcx.types.u8),
|
return false;
|
||||||
("NonZeroU16", tcx.types.u16),
|
}
|
||||||
("NonZeroU32", tcx.types.u32),
|
|
||||||
("NonZeroU64", tcx.types.u64),
|
|
||||||
("NonZeroU128", tcx.types.u128),
|
|
||||||
("NonZeroUsize", tcx.types.usize),
|
|
||||||
("NonZeroI8", tcx.types.i8),
|
|
||||||
("NonZeroI16", tcx.types.i16),
|
|
||||||
("NonZeroI32", tcx.types.i32),
|
|
||||||
("NonZeroI64", tcx.types.i64),
|
|
||||||
("NonZeroI128", tcx.types.i128),
|
|
||||||
("NonZeroIsize", tcx.types.isize),
|
|
||||||
];
|
|
||||||
|
|
||||||
let int_type = substs.type_at(0);
|
|
||||||
|
|
||||||
let Some(nonzero_alias) = coercible_types.iter().find_map(|(nonzero_alias, t)| {
|
|
||||||
if *t == int_type && *t == from_ty {
|
|
||||||
Some(nonzero_alias)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}) else {
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
span_lint_and_then(
|
span_lint_and_then(
|
||||||
cx,
|
cx,
|
||||||
TRANSMUTE_INT_TO_NON_ZERO,
|
TRANSMUTE_INT_TO_NON_ZERO,
|
||||||
e.span,
|
e.span,
|
||||||
format!("transmute from a `{from_ty}` to a `{nonzero_alias}`"),
|
format!("transmute from a `{from_ty}` to a `{}<{int_ty}>`", sym::NonZero),
|
||||||
|diag| {
|
|diag| {
|
||||||
let arg = sugg::Sugg::hir(cx, arg, "..");
|
let arg = sugg::Sugg::hir(cx, arg, "..");
|
||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
e.span,
|
e.span,
|
||||||
"consider using",
|
"consider using",
|
||||||
format!("{nonzero_alias}::{}({arg})", sym::new_unchecked),
|
format!("{}::{}({arg})", sym::NonZero, sym::new_unchecked),
|
||||||
Applicability::Unspecified,
|
Applicability::Unspecified,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#![warn(clippy::transmute_int_to_non_zero)]
|
#![warn(clippy::transmute_int_to_non_zero)]
|
||||||
#![allow(clippy::missing_transmute_annotations)]
|
#![allow(clippy::missing_transmute_annotations)]
|
||||||
|
|
||||||
use core::num::*;
|
use core::num::NonZero;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let int_u8: u8 = 1;
|
let int_u8: u8 = 1;
|
||||||
@ -16,38 +16,38 @@ fn main() {
|
|||||||
let int_i64: i64 = 1;
|
let int_i64: i64 = 1;
|
||||||
let int_i128: i128 = 1;
|
let int_i128: i128 = 1;
|
||||||
|
|
||||||
let _: NonZeroU8 = unsafe { NonZeroU8::new_unchecked(int_u8) };
|
let _: NonZero<u8> = unsafe { NonZero::new_unchecked(int_u8) };
|
||||||
//~^ ERROR: transmute from a `u8` to a `NonZeroU8`
|
//~^ ERROR: transmute from a `u8` to a `NonZero<u8>`
|
||||||
//~| NOTE: `-D clippy::transmute-int-to-non-zero` implied by `-D warnings`
|
//~| NOTE: `-D clippy::transmute-int-to-non-zero` implied by `-D warnings`
|
||||||
let _: NonZeroU16 = unsafe { NonZeroU16::new_unchecked(int_u16) };
|
let _: NonZero<u16> = unsafe { NonZero::new_unchecked(int_u16) };
|
||||||
//~^ ERROR: transmute from a `u16` to a `NonZeroU16`
|
//~^ ERROR: transmute from a `u16` to a `NonZero<u16>`
|
||||||
let _: NonZeroU32 = unsafe { NonZeroU32::new_unchecked(int_u32) };
|
let _: NonZero<u32> = unsafe { NonZero::new_unchecked(int_u32) };
|
||||||
//~^ ERROR: transmute from a `u32` to a `NonZeroU32`
|
//~^ ERROR: transmute from a `u32` to a `NonZero<u32>`
|
||||||
let _: NonZeroU64 = unsafe { NonZeroU64::new_unchecked(int_u64) };
|
let _: NonZero<u64> = unsafe { NonZero::new_unchecked(int_u64) };
|
||||||
//~^ ERROR: transmute from a `u64` to a `NonZeroU64`
|
//~^ ERROR: transmute from a `u64` to a `NonZero<u64>`
|
||||||
let _: NonZeroU128 = unsafe { NonZeroU128::new_unchecked(int_u128) };
|
let _: NonZero<u128> = unsafe { NonZero::new_unchecked(int_u128) };
|
||||||
//~^ ERROR: transmute from a `u128` to a `NonZeroU128`
|
//~^ ERROR: transmute from a `u128` to a `NonZero<u128>`
|
||||||
|
|
||||||
let _: NonZeroI8 = unsafe { NonZeroI8::new_unchecked(int_i8) };
|
let _: NonZero<i8> = unsafe { NonZero::new_unchecked(int_i8) };
|
||||||
//~^ ERROR: transmute from a `i8` to a `NonZeroI8`
|
//~^ ERROR: transmute from a `i8` to a `NonZero<i8>`
|
||||||
let _: NonZeroI16 = unsafe { NonZeroI16::new_unchecked(int_i16) };
|
let _: NonZero<i16> = unsafe { NonZero::new_unchecked(int_i16) };
|
||||||
//~^ ERROR: transmute from a `i16` to a `NonZeroI16`
|
//~^ ERROR: transmute from a `i16` to a `NonZero<i16>`
|
||||||
let _: NonZeroI32 = unsafe { NonZeroI32::new_unchecked(int_i32) };
|
let _: NonZero<i32> = unsafe { NonZero::new_unchecked(int_i32) };
|
||||||
//~^ ERROR: transmute from a `i32` to a `NonZeroI32`
|
//~^ ERROR: transmute from a `i32` to a `NonZero<i32>`
|
||||||
let _: NonZeroI64 = unsafe { NonZeroI64::new_unchecked(int_i64) };
|
let _: NonZero<i64> = unsafe { NonZero::new_unchecked(int_i64) };
|
||||||
//~^ ERROR: transmute from a `i64` to a `NonZeroI64`
|
//~^ ERROR: transmute from a `i64` to a `NonZero<i64>`
|
||||||
let _: NonZeroI128 = unsafe { NonZeroI128::new_unchecked(int_i128) };
|
let _: NonZero<i128> = unsafe { NonZero::new_unchecked(int_i128) };
|
||||||
//~^ ERROR: transmute from a `i128` to a `NonZeroI128`
|
//~^ ERROR: transmute from a `i128` to a `NonZero<i128>`
|
||||||
|
|
||||||
let _: NonZeroU8 = unsafe { NonZeroU8::new_unchecked(int_u8) };
|
let _: NonZero<u8> = unsafe { NonZero::new_unchecked(int_u8) };
|
||||||
let _: NonZeroU16 = unsafe { NonZeroU16::new_unchecked(int_u16) };
|
let _: NonZero<u16> = unsafe { NonZero::new_unchecked(int_u16) };
|
||||||
let _: NonZeroU32 = unsafe { NonZeroU32::new_unchecked(int_u32) };
|
let _: NonZero<u32> = unsafe { NonZero::new_unchecked(int_u32) };
|
||||||
let _: NonZeroU64 = unsafe { NonZeroU64::new_unchecked(int_u64) };
|
let _: NonZero<u64> = unsafe { NonZero::new_unchecked(int_u64) };
|
||||||
let _: NonZeroU128 = unsafe { NonZeroU128::new_unchecked(int_u128) };
|
let _: NonZero<u128> = unsafe { NonZero::new_unchecked(int_u128) };
|
||||||
|
|
||||||
let _: NonZeroI8 = unsafe { NonZeroI8::new_unchecked(int_i8) };
|
let _: NonZero<i8> = unsafe { NonZero::new_unchecked(int_i8) };
|
||||||
let _: NonZeroI16 = unsafe { NonZeroI16::new_unchecked(int_i16) };
|
let _: NonZero<i16> = unsafe { NonZero::new_unchecked(int_i16) };
|
||||||
let _: NonZeroI32 = unsafe { NonZeroI32::new_unchecked(int_i32) };
|
let _: NonZero<i32> = unsafe { NonZero::new_unchecked(int_i32) };
|
||||||
let _: NonZeroI64 = unsafe { NonZeroI64::new_unchecked(int_i64) };
|
let _: NonZero<i64> = unsafe { NonZero::new_unchecked(int_i64) };
|
||||||
let _: NonZeroI128 = unsafe { NonZeroI128::new_unchecked(int_i128) };
|
let _: NonZero<i128> = unsafe { NonZero::new_unchecked(int_i128) };
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#![warn(clippy::transmute_int_to_non_zero)]
|
#![warn(clippy::transmute_int_to_non_zero)]
|
||||||
#![allow(clippy::missing_transmute_annotations)]
|
#![allow(clippy::missing_transmute_annotations)]
|
||||||
|
|
||||||
use core::num::*;
|
use core::num::NonZero;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let int_u8: u8 = 1;
|
let int_u8: u8 = 1;
|
||||||
@ -16,38 +16,38 @@ fn main() {
|
|||||||
let int_i64: i64 = 1;
|
let int_i64: i64 = 1;
|
||||||
let int_i128: i128 = 1;
|
let int_i128: i128 = 1;
|
||||||
|
|
||||||
let _: NonZeroU8 = unsafe { std::mem::transmute(int_u8) };
|
let _: NonZero<u8> = unsafe { std::mem::transmute(int_u8) };
|
||||||
//~^ ERROR: transmute from a `u8` to a `NonZeroU8`
|
//~^ ERROR: transmute from a `u8` to a `NonZero<u8>`
|
||||||
//~| NOTE: `-D clippy::transmute-int-to-non-zero` implied by `-D warnings`
|
//~| NOTE: `-D clippy::transmute-int-to-non-zero` implied by `-D warnings`
|
||||||
let _: NonZeroU16 = unsafe { std::mem::transmute(int_u16) };
|
let _: NonZero<u16> = unsafe { std::mem::transmute(int_u16) };
|
||||||
//~^ ERROR: transmute from a `u16` to a `NonZeroU16`
|
//~^ ERROR: transmute from a `u16` to a `NonZero<u16>`
|
||||||
let _: NonZeroU32 = unsafe { std::mem::transmute(int_u32) };
|
let _: NonZero<u32> = unsafe { std::mem::transmute(int_u32) };
|
||||||
//~^ ERROR: transmute from a `u32` to a `NonZeroU32`
|
//~^ ERROR: transmute from a `u32` to a `NonZero<u32>`
|
||||||
let _: NonZeroU64 = unsafe { std::mem::transmute(int_u64) };
|
let _: NonZero<u64> = unsafe { std::mem::transmute(int_u64) };
|
||||||
//~^ ERROR: transmute from a `u64` to a `NonZeroU64`
|
//~^ ERROR: transmute from a `u64` to a `NonZero<u64>`
|
||||||
let _: NonZeroU128 = unsafe { std::mem::transmute(int_u128) };
|
let _: NonZero<u128> = unsafe { std::mem::transmute(int_u128) };
|
||||||
//~^ ERROR: transmute from a `u128` to a `NonZeroU128`
|
//~^ ERROR: transmute from a `u128` to a `NonZero<u128>`
|
||||||
|
|
||||||
let _: NonZeroI8 = unsafe { std::mem::transmute(int_i8) };
|
let _: NonZero<i8> = unsafe { std::mem::transmute(int_i8) };
|
||||||
//~^ ERROR: transmute from a `i8` to a `NonZeroI8`
|
//~^ ERROR: transmute from a `i8` to a `NonZero<i8>`
|
||||||
let _: NonZeroI16 = unsafe { std::mem::transmute(int_i16) };
|
let _: NonZero<i16> = unsafe { std::mem::transmute(int_i16) };
|
||||||
//~^ ERROR: transmute from a `i16` to a `NonZeroI16`
|
//~^ ERROR: transmute from a `i16` to a `NonZero<i16>`
|
||||||
let _: NonZeroI32 = unsafe { std::mem::transmute(int_i32) };
|
let _: NonZero<i32> = unsafe { std::mem::transmute(int_i32) };
|
||||||
//~^ ERROR: transmute from a `i32` to a `NonZeroI32`
|
//~^ ERROR: transmute from a `i32` to a `NonZero<i32>`
|
||||||
let _: NonZeroI64 = unsafe { std::mem::transmute(int_i64) };
|
let _: NonZero<i64> = unsafe { std::mem::transmute(int_i64) };
|
||||||
//~^ ERROR: transmute from a `i64` to a `NonZeroI64`
|
//~^ ERROR: transmute from a `i64` to a `NonZero<i64>`
|
||||||
let _: NonZeroI128 = unsafe { std::mem::transmute(int_i128) };
|
let _: NonZero<i128> = unsafe { std::mem::transmute(int_i128) };
|
||||||
//~^ ERROR: transmute from a `i128` to a `NonZeroI128`
|
//~^ ERROR: transmute from a `i128` to a `NonZero<i128>`
|
||||||
|
|
||||||
let _: NonZeroU8 = unsafe { NonZeroU8::new_unchecked(int_u8) };
|
let _: NonZero<u8> = unsafe { NonZero::new_unchecked(int_u8) };
|
||||||
let _: NonZeroU16 = unsafe { NonZeroU16::new_unchecked(int_u16) };
|
let _: NonZero<u16> = unsafe { NonZero::new_unchecked(int_u16) };
|
||||||
let _: NonZeroU32 = unsafe { NonZeroU32::new_unchecked(int_u32) };
|
let _: NonZero<u32> = unsafe { NonZero::new_unchecked(int_u32) };
|
||||||
let _: NonZeroU64 = unsafe { NonZeroU64::new_unchecked(int_u64) };
|
let _: NonZero<u64> = unsafe { NonZero::new_unchecked(int_u64) };
|
||||||
let _: NonZeroU128 = unsafe { NonZeroU128::new_unchecked(int_u128) };
|
let _: NonZero<u128> = unsafe { NonZero::new_unchecked(int_u128) };
|
||||||
|
|
||||||
let _: NonZeroI8 = unsafe { NonZeroI8::new_unchecked(int_i8) };
|
let _: NonZero<i8> = unsafe { NonZero::new_unchecked(int_i8) };
|
||||||
let _: NonZeroI16 = unsafe { NonZeroI16::new_unchecked(int_i16) };
|
let _: NonZero<i16> = unsafe { NonZero::new_unchecked(int_i16) };
|
||||||
let _: NonZeroI32 = unsafe { NonZeroI32::new_unchecked(int_i32) };
|
let _: NonZero<i32> = unsafe { NonZero::new_unchecked(int_i32) };
|
||||||
let _: NonZeroI64 = unsafe { NonZeroI64::new_unchecked(int_i64) };
|
let _: NonZero<i64> = unsafe { NonZero::new_unchecked(int_i64) };
|
||||||
let _: NonZeroI128 = unsafe { NonZeroI128::new_unchecked(int_i128) };
|
let _: NonZero<i128> = unsafe { NonZero::new_unchecked(int_i128) };
|
||||||
}
|
}
|
||||||
|
@ -1,65 +1,65 @@
|
|||||||
error: transmute from a `u8` to a `NonZeroU8`
|
error: transmute from a `u8` to a `NonZero<u8>`
|
||||||
--> tests/ui/transmute_int_to_non_zero.rs:19:33
|
--> tests/ui/transmute_int_to_non_zero.rs:19:35
|
||||||
|
|
|
|
||||||
LL | let _: NonZeroU8 = unsafe { std::mem::transmute(int_u8) };
|
LL | let _: NonZero<u8> = unsafe { std::mem::transmute(int_u8) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroU8::new_unchecked(int_u8)`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZero::new_unchecked(int_u8)`
|
||||||
|
|
|
|
||||||
= note: `-D clippy::transmute-int-to-non-zero` implied by `-D warnings`
|
= note: `-D clippy::transmute-int-to-non-zero` implied by `-D warnings`
|
||||||
= help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_non_zero)]`
|
= help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_non_zero)]`
|
||||||
|
|
||||||
error: transmute from a `u16` to a `NonZeroU16`
|
error: transmute from a `u16` to a `NonZero<u16>`
|
||||||
--> tests/ui/transmute_int_to_non_zero.rs:22:34
|
--> tests/ui/transmute_int_to_non_zero.rs:22:36
|
||||||
|
|
|
|
||||||
LL | let _: NonZeroU16 = unsafe { std::mem::transmute(int_u16) };
|
LL | let _: NonZero<u16> = unsafe { std::mem::transmute(int_u16) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroU16::new_unchecked(int_u16)`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZero::new_unchecked(int_u16)`
|
||||||
|
|
||||||
error: transmute from a `u32` to a `NonZeroU32`
|
error: transmute from a `u32` to a `NonZero<u32>`
|
||||||
--> tests/ui/transmute_int_to_non_zero.rs:24:34
|
--> tests/ui/transmute_int_to_non_zero.rs:24:36
|
||||||
|
|
|
|
||||||
LL | let _: NonZeroU32 = unsafe { std::mem::transmute(int_u32) };
|
LL | let _: NonZero<u32> = unsafe { std::mem::transmute(int_u32) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroU32::new_unchecked(int_u32)`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZero::new_unchecked(int_u32)`
|
||||||
|
|
||||||
error: transmute from a `u64` to a `NonZeroU64`
|
error: transmute from a `u64` to a `NonZero<u64>`
|
||||||
--> tests/ui/transmute_int_to_non_zero.rs:26:34
|
--> tests/ui/transmute_int_to_non_zero.rs:26:36
|
||||||
|
|
|
|
||||||
LL | let _: NonZeroU64 = unsafe { std::mem::transmute(int_u64) };
|
LL | let _: NonZero<u64> = unsafe { std::mem::transmute(int_u64) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroU64::new_unchecked(int_u64)`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZero::new_unchecked(int_u64)`
|
||||||
|
|
||||||
error: transmute from a `u128` to a `NonZeroU128`
|
error: transmute from a `u128` to a `NonZero<u128>`
|
||||||
--> tests/ui/transmute_int_to_non_zero.rs:28:35
|
--> tests/ui/transmute_int_to_non_zero.rs:28:37
|
||||||
|
|
|
|
||||||
LL | let _: NonZeroU128 = unsafe { std::mem::transmute(int_u128) };
|
LL | let _: NonZero<u128> = unsafe { std::mem::transmute(int_u128) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroU128::new_unchecked(int_u128)`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZero::new_unchecked(int_u128)`
|
||||||
|
|
||||||
error: transmute from a `i8` to a `NonZeroI8`
|
error: transmute from a `i8` to a `NonZero<i8>`
|
||||||
--> tests/ui/transmute_int_to_non_zero.rs:31:33
|
--> tests/ui/transmute_int_to_non_zero.rs:31:35
|
||||||
|
|
|
|
||||||
LL | let _: NonZeroI8 = unsafe { std::mem::transmute(int_i8) };
|
LL | let _: NonZero<i8> = unsafe { std::mem::transmute(int_i8) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroI8::new_unchecked(int_i8)`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZero::new_unchecked(int_i8)`
|
||||||
|
|
||||||
error: transmute from a `i16` to a `NonZeroI16`
|
error: transmute from a `i16` to a `NonZero<i16>`
|
||||||
--> tests/ui/transmute_int_to_non_zero.rs:33:34
|
--> tests/ui/transmute_int_to_non_zero.rs:33:36
|
||||||
|
|
|
|
||||||
LL | let _: NonZeroI16 = unsafe { std::mem::transmute(int_i16) };
|
LL | let _: NonZero<i16> = unsafe { std::mem::transmute(int_i16) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroI16::new_unchecked(int_i16)`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZero::new_unchecked(int_i16)`
|
||||||
|
|
||||||
error: transmute from a `i32` to a `NonZeroI32`
|
error: transmute from a `i32` to a `NonZero<i32>`
|
||||||
--> tests/ui/transmute_int_to_non_zero.rs:35:34
|
--> tests/ui/transmute_int_to_non_zero.rs:35:36
|
||||||
|
|
|
|
||||||
LL | let _: NonZeroI32 = unsafe { std::mem::transmute(int_i32) };
|
LL | let _: NonZero<i32> = unsafe { std::mem::transmute(int_i32) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroI32::new_unchecked(int_i32)`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZero::new_unchecked(int_i32)`
|
||||||
|
|
||||||
error: transmute from a `i64` to a `NonZeroI64`
|
error: transmute from a `i64` to a `NonZero<i64>`
|
||||||
--> tests/ui/transmute_int_to_non_zero.rs:37:34
|
--> tests/ui/transmute_int_to_non_zero.rs:37:36
|
||||||
|
|
|
|
||||||
LL | let _: NonZeroI64 = unsafe { std::mem::transmute(int_i64) };
|
LL | let _: NonZero<i64> = unsafe { std::mem::transmute(int_i64) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroI64::new_unchecked(int_i64)`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZero::new_unchecked(int_i64)`
|
||||||
|
|
||||||
error: transmute from a `i128` to a `NonZeroI128`
|
error: transmute from a `i128` to a `NonZero<i128>`
|
||||||
--> tests/ui/transmute_int_to_non_zero.rs:39:35
|
--> tests/ui/transmute_int_to_non_zero.rs:39:37
|
||||||
|
|
|
|
||||||
LL | let _: NonZeroI128 = unsafe { std::mem::transmute(int_i128) };
|
LL | let _: NonZero<i128> = unsafe { std::mem::transmute(int_i128) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroI128::new_unchecked(int_i128)`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZero::new_unchecked(int_i128)`
|
||||||
|
|
||||||
error: aborting due to 10 previous errors
|
error: aborting due to 10 previous errors
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user