Merge remote-tracking branch 'upstream/master' into rustup
diff --git a/clippy_lints/src/dereference.rs b/clippy_lints/src/dereference.rs
index 7da5a53..5edb5c2 100644
--- a/clippy_lints/src/dereference.rs
+++ b/clippy_lints/src/dereference.rs
@@ -853,7 +853,7 @@
continue;
},
ty::Param(_) if for_return => Self::Deref,
- ty::Alias(ty::Weak | ty::Inherent, _) => unreachable!("should have been normalized away above"),
+ ty::Alias(ty::Free | ty::Inherent, _) => unreachable!("should have been normalized away above"),
ty::Alias(ty::Projection, _) if !for_return && ty.has_non_region_param() => Self::Reborrow,
ty::Infer(_)
| ty::Error(_)
diff --git a/clippy_lints/src/missing_const_for_fn.rs b/clippy_lints/src/missing_const_for_fn.rs
index 67537a2..1f142bc 100644
--- a/clippy_lints/src/missing_const_for_fn.rs
+++ b/clippy_lints/src/missing_const_for_fn.rs
@@ -197,7 +197,7 @@
inputs.iter().any(|input| {
matches!(
input.kind(),
- ty::Alias(ty::AliasTyKind::Weak, alias_ty) if cx.tcx.type_of(alias_ty.def_id).skip_binder().is_impl_trait()
+ ty::Alias(ty::AliasTyKind::Free, alias_ty) if cx.tcx.type_of(alias_ty.def_id).skip_binder().is_impl_trait()
)
})
}
diff --git a/clippy_utils/src/hir_utils.rs b/clippy_utils/src/hir_utils.rs
index fe1fd70..c37231d 100644
--- a/clippy_utils/src/hir_utils.rs
+++ b/clippy_utils/src/hir_utils.rs
@@ -1117,6 +1117,11 @@
self.hash_const_arg(s);
self.hash_const_arg(e);
},
+ TyPatKind::Or(variants) => {
+ for variant in variants {
+ self.hash_ty_pat(variant);
+ }
+ },
TyPatKind::Err(_) => {},
}
}
diff --git a/clippy_utils/src/source.rs b/clippy_utils/src/source.rs
index 3aa72cf..8645d57 100644
--- a/clippy_utils/src/source.rs
+++ b/clippy_utils/src/source.rs
@@ -142,6 +142,7 @@
map_range(cx.sess().source_map(), self.into_range(), f)
}
+ #[allow(rustdoc::invalid_rust_codeblocks, reason = "The codeblock is intentionally broken")]
/// Extends the range to include all preceding whitespace characters, unless there
/// are non-whitespace characters left on the same line after `self`.
///
diff --git a/tests/ui/blocks_in_conditions.fixed b/tests/ui/blocks_in_conditions.fixed
index c82276b..6ae5b0c 100644
--- a/tests/ui/blocks_in_conditions.fixed
+++ b/tests/ui/blocks_in_conditions.fixed
@@ -1,7 +1,12 @@
//@aux-build:proc_macro_attr.rs
#![warn(clippy::blocks_in_conditions)]
-#![allow(unused, clippy::needless_if, clippy::missing_transmute_annotations)]
+#![allow(
+ unused,
+ unnecessary_transmutes,
+ clippy::needless_if,
+ clippy::missing_transmute_annotations
+)]
#![warn(clippy::nonminimal_bool)]
macro_rules! blocky {
diff --git a/tests/ui/blocks_in_conditions.rs b/tests/ui/blocks_in_conditions.rs
index 6a4a7c6..3fd0606 100644
--- a/tests/ui/blocks_in_conditions.rs
+++ b/tests/ui/blocks_in_conditions.rs
@@ -1,7 +1,12 @@
//@aux-build:proc_macro_attr.rs
#![warn(clippy::blocks_in_conditions)]
-#![allow(unused, clippy::needless_if, clippy::missing_transmute_annotations)]
+#![allow(
+ unused,
+ unnecessary_transmutes,
+ clippy::needless_if,
+ clippy::missing_transmute_annotations
+)]
#![warn(clippy::nonminimal_bool)]
macro_rules! blocky {
diff --git a/tests/ui/blocks_in_conditions.stderr b/tests/ui/blocks_in_conditions.stderr
index e57eca5..282c42a 100644
--- a/tests/ui/blocks_in_conditions.stderr
+++ b/tests/ui/blocks_in_conditions.stderr
@@ -1,5 +1,5 @@
error: in an `if` condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let`
- --> tests/ui/blocks_in_conditions.rs:25:5
+ --> tests/ui/blocks_in_conditions.rs:30:5
|
LL | / if {
LL | |
@@ -20,13 +20,13 @@
|
error: omit braces around single expression condition
- --> tests/ui/blocks_in_conditions.rs:37:8
+ --> tests/ui/blocks_in_conditions.rs:42:8
|
LL | if { true } { 6 } else { 10 }
| ^^^^^^^^ help: try: `true`
error: this boolean expression can be simplified
- --> tests/ui/blocks_in_conditions.rs:43:8
+ --> tests/ui/blocks_in_conditions.rs:48:8
|
LL | if true && x == 3 { 6 } else { 10 }
| ^^^^^^^^^^^^^^ help: try: `x == 3`
diff --git a/tests/ui/checked_unwrap/simple_conditionals.stderr b/tests/ui/checked_unwrap/simple_conditionals.stderr
index bdac1e4..ad3c420 100644
--- a/tests/ui/checked_unwrap/simple_conditionals.stderr
+++ b/tests/ui/checked_unwrap/simple_conditionals.stderr
@@ -236,7 +236,7 @@
LL | result.as_mut().unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^
-error: creating a shared reference to mutable static is discouraged
+error: creating a shared reference to mutable static
--> tests/ui/checked_unwrap/simple_conditionals.rs:183:12
|
LL | if X.is_some() {
diff --git a/tests/ui/crashes/ice-1782.rs b/tests/ui/crashes/ice-1782.rs
index 4a1886c..776b0a9 100644
--- a/tests/ui/crashes/ice-1782.rs
+++ b/tests/ui/crashes/ice-1782.rs
@@ -1,6 +1,6 @@
//@ check-pass
-#![allow(dead_code, unused_variables, invalid_null_arguments)]
+#![allow(dead_code, unused_variables, invalid_null_arguments, unnecessary_transmutes)]
#![allow(clippy::unnecessary_cast, clippy::missing_transmute_annotations)]
/// Should not trigger an ICE in `SpanlessEq` / `consts::constant`
diff --git a/tests/ui/needless_if.fixed b/tests/ui/needless_if.fixed
index 6208ca1..347dbff 100644
--- a/tests/ui/needless_if.fixed
+++ b/tests/ui/needless_if.fixed
@@ -46,9 +46,7 @@
if let true = true
&& true
{}
- if true
- && let true = true
- {}
+ if true && let true = true {}
// Can lint nested `if let`s
({
//~^ needless_if
diff --git a/tests/ui/needless_if.rs b/tests/ui/needless_if.rs
index b459ff8..5e0f2a1 100644
--- a/tests/ui/needless_if.rs
+++ b/tests/ui/needless_if.rs
@@ -46,9 +46,7 @@
if let true = true
&& true
{}
- if true
- && let true = true
- {}
+ if true && let true = true {}
// Can lint nested `if let`s
if {
//~^ needless_if
diff --git a/tests/ui/needless_if.stderr b/tests/ui/needless_if.stderr
index eeb8d04..62cdf24 100644
--- a/tests/ui/needless_if.stderr
+++ b/tests/ui/needless_if.stderr
@@ -31,7 +31,7 @@
|
error: this `if` branch is empty
- --> tests/ui/needless_if.rs:53:5
+ --> tests/ui/needless_if.rs:51:5
|
LL | / if {
LL | |
@@ -57,19 +57,19 @@
|
error: this `if` branch is empty
- --> tests/ui/needless_if.rs:98:5
+ --> tests/ui/needless_if.rs:96:5
|
LL | if { maybe_side_effect() } {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can remove it: `({ maybe_side_effect() });`
error: this `if` branch is empty
- --> tests/ui/needless_if.rs:101:5
+ --> tests/ui/needless_if.rs:99:5
|
LL | if { maybe_side_effect() } && true {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can remove it: `({ maybe_side_effect() } && true);`
error: this `if` branch is empty
- --> tests/ui/needless_if.rs:106:5
+ --> tests/ui/needless_if.rs:104:5
|
LL | if true {}
| ^^^^^^^^^^ help: you can remove it: `true;`
diff --git a/tests/ui/needless_late_init.fixed b/tests/ui/needless_late_init.fixed
index 391d4bc..f832752 100644
--- a/tests/ui/needless_late_init.fixed
+++ b/tests/ui/needless_late_init.fixed
@@ -246,9 +246,7 @@
}
let x;
- if true
- && let Some(n) = Some("let chains too")
- {
+ if true && let Some(n) = Some("let chains too") {
x = 1;
} else {
x = 2;
diff --git a/tests/ui/needless_late_init.rs b/tests/ui/needless_late_init.rs
index 6096e83..a52fbf5 100644
--- a/tests/ui/needless_late_init.rs
+++ b/tests/ui/needless_late_init.rs
@@ -246,9 +246,7 @@
}
let x;
- if true
- && let Some(n) = Some("let chains too")
- {
+ if true && let Some(n) = Some("let chains too") {
x = 1;
} else {
x = 2;
diff --git a/tests/ui/needless_late_init.stderr b/tests/ui/needless_late_init.stderr
index e7c3613..b24c127 100644
--- a/tests/ui/needless_late_init.stderr
+++ b/tests/ui/needless_late_init.stderr
@@ -276,7 +276,7 @@
|
error: unneeded late initialization
- --> tests/ui/needless_late_init.rs:302:5
+ --> tests/ui/needless_late_init.rs:300:5
|
LL | let r;
| ^^^^^^ created here
diff --git a/tests/ui/ptr_eq.fixed b/tests/ui/ptr_eq.fixed
index f0150e6..9629b3e 100644
--- a/tests/ui/ptr_eq.fixed
+++ b/tests/ui/ptr_eq.fixed
@@ -60,4 +60,8 @@
// Do not peel the content of macros
let _ = std::ptr::eq(mac!(cast a), mac!(cast b));
//~^ ptr_eq
+
+ // Do not peel the content of macros
+ let _ = std::ptr::eq(mac!(cast a), mac!(cast b));
+ //~^ ptr_eq
}
diff --git a/tests/ui/ptr_eq.rs b/tests/ui/ptr_eq.rs
index 3fb8925..2b741d8 100644
--- a/tests/ui/ptr_eq.rs
+++ b/tests/ui/ptr_eq.rs
@@ -60,4 +60,8 @@
// Do not peel the content of macros
let _ = mac!(cast a) as *const _ == mac!(cast b) as *const _;
//~^ ptr_eq
+
+ // Do not peel the content of macros
+ let _ = mac!(cast a) as *const _ == mac!(cast b) as *const _;
+ //~^ ptr_eq
}
diff --git a/tests/ui/ptr_eq.stderr b/tests/ui/ptr_eq.stderr
index f613e16..e734062 100644
--- a/tests/ui/ptr_eq.stderr
+++ b/tests/ui/ptr_eq.stderr
@@ -31,5 +31,11 @@
LL | let _ = mac!(cast a) as *const _ == mac!(cast b) as *const _;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::eq(mac!(cast a), mac!(cast b))`
-error: aborting due to 5 previous errors
+error: use `std::ptr::eq` when comparing raw pointers
+ --> tests/ui/ptr_eq.rs:65:13
+ |
+LL | let _ = mac!(cast a) as *const _ == mac!(cast b) as *const _;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::eq(mac!(cast a), mac!(cast b))`
+
+error: aborting due to 6 previous errors
diff --git a/tests/ui/transmute.rs b/tests/ui/transmute.rs
index 8c8674a..2b8b6c5 100644
--- a/tests/ui/transmute.rs
+++ b/tests/ui/transmute.rs
@@ -3,6 +3,7 @@
#![allow(
dead_code,
clippy::borrow_as_ptr,
+ unnecessary_transmutes,
clippy::needless_lifetimes,
clippy::missing_transmute_annotations
)]
diff --git a/tests/ui/transmute.stderr b/tests/ui/transmute.stderr
index 4219e09..1bb7015 100644
--- a/tests/ui/transmute.stderr
+++ b/tests/ui/transmute.stderr
@@ -1,5 +1,5 @@
error: transmute from a reference to a pointer
- --> tests/ui/transmute.rs:32:27
+ --> tests/ui/transmute.rs:33:27
|
LL | let _: *const T = core::mem::transmute(t);
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T`
@@ -8,61 +8,61 @@
= help: to override `-D warnings` add `#[allow(clippy::useless_transmute)]`
error: transmute from a reference to a pointer
- --> tests/ui/transmute.rs:35:25
+ --> tests/ui/transmute.rs:36:25
|
LL | let _: *mut T = core::mem::transmute(t);
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *mut T`
error: transmute from a reference to a pointer
- --> tests/ui/transmute.rs:38:27
+ --> tests/ui/transmute.rs:39:27
|
LL | let _: *const U = core::mem::transmute(t);
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *const U`
error: transmute from a type (`std::vec::Vec<i32>`) to itself
- --> tests/ui/transmute.rs:46:27
+ --> tests/ui/transmute.rs:47:27
|
LL | let _: Vec<i32> = core::mem::transmute(my_vec());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: transmute from a type (`std::vec::Vec<i32>`) to itself
- --> tests/ui/transmute.rs:49:27
+ --> tests/ui/transmute.rs:50:27
|
LL | let _: Vec<i32> = core::mem::transmute(my_vec());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: transmute from a type (`std::vec::Vec<i32>`) to itself
- --> tests/ui/transmute.rs:52:27
+ --> tests/ui/transmute.rs:53:27
|
LL | let _: Vec<i32> = std::mem::transmute(my_vec());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: transmute from a type (`std::vec::Vec<i32>`) to itself
- --> tests/ui/transmute.rs:55:27
+ --> tests/ui/transmute.rs:56:27
|
LL | let _: Vec<i32> = std::mem::transmute(my_vec());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: transmute from a type (`std::vec::Vec<i32>`) to itself
- --> tests/ui/transmute.rs:58:27
+ --> tests/ui/transmute.rs:59:27
|
LL | let _: Vec<i32> = my_transmute(my_vec());
| ^^^^^^^^^^^^^^^^^^^^^^
error: transmute from an integer to a pointer
- --> tests/ui/transmute.rs:61:31
+ --> tests/ui/transmute.rs:62:31
|
LL | let _: *const usize = std::mem::transmute(5_isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `5_isize as *const usize`
error: transmute from an integer to a pointer
- --> tests/ui/transmute.rs:66:31
+ --> tests/ui/transmute.rs:67:31
|
LL | let _: *const usize = std::mem::transmute(1 + 1usize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(1 + 1usize) as *const usize`
error: transmute from a type (`*const Usize`) to the type that it points to (`Usize`)
- --> tests/ui/transmute.rs:98:24
+ --> tests/ui/transmute.rs:99:24
|
LL | let _: Usize = core::mem::transmute(int_const_ptr);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -71,25 +71,25 @@
= help: to override `-D warnings` add `#[allow(clippy::crosspointer_transmute)]`
error: transmute from a type (`*mut Usize`) to the type that it points to (`Usize`)
- --> tests/ui/transmute.rs:101:24
+ --> tests/ui/transmute.rs:102:24
|
LL | let _: Usize = core::mem::transmute(int_mut_ptr);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: transmute from a type (`Usize`) to a pointer to that type (`*const Usize`)
- --> tests/ui/transmute.rs:104:31
+ --> tests/ui/transmute.rs:105:31
|
LL | let _: *const Usize = core::mem::transmute(my_int());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: transmute from a type (`Usize`) to a pointer to that type (`*mut Usize`)
- --> tests/ui/transmute.rs:107:29
+ --> tests/ui/transmute.rs:108:29
|
LL | let _: *mut Usize = core::mem::transmute(my_int());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: transmute from a `u8` to a `bool`
- --> tests/ui/transmute.rs:114:28
+ --> tests/ui/transmute.rs:115:28
|
LL | let _: bool = unsafe { std::mem::transmute(0_u8) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `0_u8 != 0`
@@ -98,7 +98,7 @@
= help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_bool)]`
error: transmute from a `u16` to a `f16`
- --> tests/ui/transmute.rs:121:31
+ --> tests/ui/transmute.rs:122:31
|
LL | let _: f16 = unsafe { std::mem::transmute(0_u16) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f16::from_bits(0_u16)`
@@ -107,97 +107,97 @@
= help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_float)]`
error: transmute from a `i16` to a `f16`
- --> tests/ui/transmute.rs:124:31
+ --> tests/ui/transmute.rs:125:31
|
LL | let _: f16 = unsafe { std::mem::transmute(0_i16) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f16::from_bits(0_i16 as u16)`
error: transmute from a `u32` to a `f32`
- --> tests/ui/transmute.rs:127:31
+ --> tests/ui/transmute.rs:128:31
|
LL | let _: f32 = unsafe { std::mem::transmute(0_u32) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_u32)`
error: transmute from a `i32` to a `f32`
- --> tests/ui/transmute.rs:130:31
+ --> tests/ui/transmute.rs:131:31
|
LL | let _: f32 = unsafe { std::mem::transmute(0_i32) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_i32 as u32)`
error: transmute from a `u64` to a `f64`
- --> tests/ui/transmute.rs:133:31
+ --> tests/ui/transmute.rs:134:31
|
LL | let _: f64 = unsafe { std::mem::transmute(0_u64) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f64::from_bits(0_u64)`
error: transmute from a `i64` to a `f64`
- --> tests/ui/transmute.rs:136:31
+ --> tests/ui/transmute.rs:137:31
|
LL | let _: f64 = unsafe { std::mem::transmute(0_i64) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f64::from_bits(0_i64 as u64)`
error: transmute from a `u128` to a `f128`
- --> tests/ui/transmute.rs:139:32
+ --> tests/ui/transmute.rs:140:32
|
LL | let _: f128 = unsafe { std::mem::transmute(0_u128) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f128::from_bits(0_u128)`
error: transmute from a `i128` to a `f128`
- --> tests/ui/transmute.rs:142:32
+ --> tests/ui/transmute.rs:143:32
|
LL | let _: f128 = unsafe { std::mem::transmute(0_i128) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f128::from_bits(0_i128 as u128)`
error: transmute from a `u16` to a `f16`
- --> tests/ui/transmute.rs:147:39
+ --> tests/ui/transmute.rs:148:39
|
LL | const VALUE16: f16 = unsafe { std::mem::transmute(0_u16) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f16::from_bits(0_u16)`
error: transmute from a `u32` to a `f32`
- --> tests/ui/transmute.rs:150:39
+ --> tests/ui/transmute.rs:151:39
|
LL | const VALUE32: f32 = unsafe { std::mem::transmute(0_u32) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_u32)`
error: transmute from a `i64` to a `f64`
- --> tests/ui/transmute.rs:153:39
+ --> tests/ui/transmute.rs:154:39
|
LL | const VALUE64: f64 = unsafe { std::mem::transmute(0_i64) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f64::from_bits(0_i64 as u64)`
error: transmute from a `i128` to a `f128`
- --> tests/ui/transmute.rs:156:41
+ --> tests/ui/transmute.rs:157:41
|
LL | const VALUE128: f128 = unsafe { std::mem::transmute(0_i128) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f128::from_bits(0_i128 as u128)`
error: transmute from a `i16` to a `f16`
- --> tests/ui/transmute.rs:160:22
+ --> tests/ui/transmute.rs:161:22
|
LL | unsafe { std::mem::transmute(v) }
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f16::from_bits(v as u16)`
error: transmute from a `i32` to a `f32`
- --> tests/ui/transmute.rs:165:22
+ --> tests/ui/transmute.rs:166:22
|
LL | unsafe { std::mem::transmute(v) }
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(v as u32)`
error: transmute from a `u64` to a `f64`
- --> tests/ui/transmute.rs:170:22
+ --> tests/ui/transmute.rs:171:22
|
LL | unsafe { std::mem::transmute(v) }
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f64::from_bits(v)`
error: transmute from a `u128` to a `f128`
- --> tests/ui/transmute.rs:175:22
+ --> tests/ui/transmute.rs:176:22
|
LL | unsafe { std::mem::transmute(v) }
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f128::from_bits(v)`
error: transmute from a `u8` to a `[u8; 1]`
- --> tests/ui/transmute.rs:184:30
+ --> tests/ui/transmute.rs:185:30
|
LL | let _: [u8; 1] = std::mem::transmute(0u8);
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u8.to_ne_bytes()`
@@ -206,121 +206,121 @@
= help: to override `-D warnings` add `#[allow(clippy::transmute_num_to_bytes)]`
error: transmute from a `u32` to a `[u8; 4]`
- --> tests/ui/transmute.rs:187:30
+ --> tests/ui/transmute.rs:188:30
|
LL | let _: [u8; 4] = std::mem::transmute(0u32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u32.to_ne_bytes()`
error: transmute from a `u128` to a `[u8; 16]`
- --> tests/ui/transmute.rs:190:31
+ --> tests/ui/transmute.rs:191:31
|
LL | let _: [u8; 16] = std::mem::transmute(0u128);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u128.to_ne_bytes()`
error: transmute from a `i8` to a `[u8; 1]`
- --> tests/ui/transmute.rs:193:30
+ --> tests/ui/transmute.rs:194:30
|
LL | let _: [u8; 1] = std::mem::transmute(0i8);
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i8.to_ne_bytes()`
error: transmute from a `i32` to a `[u8; 4]`
- --> tests/ui/transmute.rs:196:30
+ --> tests/ui/transmute.rs:197:30
|
LL | let _: [u8; 4] = std::mem::transmute(0i32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i32.to_ne_bytes()`
error: transmute from a `i128` to a `[u8; 16]`
- --> tests/ui/transmute.rs:199:31
+ --> tests/ui/transmute.rs:200:31
|
LL | let _: [u8; 16] = std::mem::transmute(0i128);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i128.to_ne_bytes()`
error: transmute from a `f16` to a `[u8; 2]`
- --> tests/ui/transmute.rs:202:30
+ --> tests/ui/transmute.rs:203:30
|
LL | let _: [u8; 2] = std::mem::transmute(0.0f16);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f16.to_ne_bytes()`
error: transmute from a `f32` to a `[u8; 4]`
- --> tests/ui/transmute.rs:205:30
+ --> tests/ui/transmute.rs:206:30
|
LL | let _: [u8; 4] = std::mem::transmute(0.0f32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f32.to_ne_bytes()`
error: transmute from a `f64` to a `[u8; 8]`
- --> tests/ui/transmute.rs:208:30
+ --> tests/ui/transmute.rs:209:30
|
LL | let _: [u8; 8] = std::mem::transmute(0.0f64);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f64.to_ne_bytes()`
error: transmute from a `f128` to a `[u8; 16]`
- --> tests/ui/transmute.rs:211:31
+ --> tests/ui/transmute.rs:212:31
|
LL | let _: [u8; 16] = std::mem::transmute(0.0f128);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f128.to_ne_bytes()`
error: transmute from a `u8` to a `[u8; 1]`
- --> tests/ui/transmute.rs:217:30
+ --> tests/ui/transmute.rs:218:30
|
LL | let _: [u8; 1] = std::mem::transmute(0u8);
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u8.to_ne_bytes()`
error: transmute from a `u32` to a `[u8; 4]`
- --> tests/ui/transmute.rs:220:30
+ --> tests/ui/transmute.rs:221:30
|
LL | let _: [u8; 4] = std::mem::transmute(0u32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u32.to_ne_bytes()`
error: transmute from a `u128` to a `[u8; 16]`
- --> tests/ui/transmute.rs:223:31
+ --> tests/ui/transmute.rs:224:31
|
LL | let _: [u8; 16] = std::mem::transmute(0u128);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u128.to_ne_bytes()`
error: transmute from a `i8` to a `[u8; 1]`
- --> tests/ui/transmute.rs:226:30
+ --> tests/ui/transmute.rs:227:30
|
LL | let _: [u8; 1] = std::mem::transmute(0i8);
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i8.to_ne_bytes()`
error: transmute from a `i32` to a `[u8; 4]`
- --> tests/ui/transmute.rs:229:30
+ --> tests/ui/transmute.rs:230:30
|
LL | let _: [u8; 4] = std::mem::transmute(0i32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i32.to_ne_bytes()`
error: transmute from a `i128` to a `[u8; 16]`
- --> tests/ui/transmute.rs:232:31
+ --> tests/ui/transmute.rs:233:31
|
LL | let _: [u8; 16] = std::mem::transmute(0i128);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i128.to_ne_bytes()`
error: transmute from a `f16` to a `[u8; 2]`
- --> tests/ui/transmute.rs:235:30
+ --> tests/ui/transmute.rs:236:30
|
LL | let _: [u8; 2] = std::mem::transmute(0.0f16);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f16.to_ne_bytes()`
error: transmute from a `f32` to a `[u8; 4]`
- --> tests/ui/transmute.rs:238:30
+ --> tests/ui/transmute.rs:239:30
|
LL | let _: [u8; 4] = std::mem::transmute(0.0f32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f32.to_ne_bytes()`
error: transmute from a `f64` to a `[u8; 8]`
- --> tests/ui/transmute.rs:241:30
+ --> tests/ui/transmute.rs:242:30
|
LL | let _: [u8; 8] = std::mem::transmute(0.0f64);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f64.to_ne_bytes()`
error: transmute from a `f128` to a `[u8; 16]`
- --> tests/ui/transmute.rs:244:31
+ --> tests/ui/transmute.rs:245:31
|
LL | let _: [u8; 16] = std::mem::transmute(0.0f128);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f128.to_ne_bytes()`
error: transmute from a `&[u8]` to a `&str`
- --> tests/ui/transmute.rs:253:28
+ --> tests/ui/transmute.rs:254:28
|
LL | let _: &str = unsafe { std::mem::transmute(B) };
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8(B).unwrap()`
@@ -329,13 +329,13 @@
= help: to override `-D warnings` add `#[allow(clippy::transmute_bytes_to_str)]`
error: transmute from a `&mut [u8]` to a `&mut str`
- --> tests/ui/transmute.rs:256:32
+ --> tests/ui/transmute.rs:257:32
|
LL | let _: &mut str = unsafe { std::mem::transmute(mb) };
| ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8_mut(mb).unwrap()`
error: transmute from a `&[u8]` to a `&str`
- --> tests/ui/transmute.rs:259:30
+ --> tests/ui/transmute.rs:260:30
|
LL | const _: &str = unsafe { std::mem::transmute(B) };
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8_unchecked(B)`
diff --git a/tests/ui/transmute_float_to_int.fixed b/tests/ui/transmute_float_to_int.fixed
index 1f97b99..8444459 100644
--- a/tests/ui/transmute_float_to_int.fixed
+++ b/tests/ui/transmute_float_to_int.fixed
@@ -1,5 +1,5 @@
#![warn(clippy::transmute_float_to_int)]
-#![allow(clippy::missing_transmute_annotations)]
+#![allow(clippy::missing_transmute_annotations, unnecessary_transmutes)]
#![feature(f128)]
#![feature(f16)]
diff --git a/tests/ui/transmute_float_to_int.rs b/tests/ui/transmute_float_to_int.rs
index 788a7e1..a1f3b15 100644
--- a/tests/ui/transmute_float_to_int.rs
+++ b/tests/ui/transmute_float_to_int.rs
@@ -1,5 +1,5 @@
#![warn(clippy::transmute_float_to_int)]
-#![allow(clippy::missing_transmute_annotations)]
+#![allow(clippy::missing_transmute_annotations, unnecessary_transmutes)]
#![feature(f128)]
#![feature(f16)]
diff --git a/tests/ui/transmute_int_to_char.fixed b/tests/ui/transmute_int_to_char.fixed
index b5425a2..28644aa 100644
--- a/tests/ui/transmute_int_to_char.fixed
+++ b/tests/ui/transmute_int_to_char.fixed
@@ -1,5 +1,5 @@
#![warn(clippy::transmute_int_to_char)]
-#![allow(clippy::missing_transmute_annotations)]
+#![allow(clippy::missing_transmute_annotations, unnecessary_transmutes)]
fn int_to_char() {
let _: char = unsafe { std::char::from_u32(0_u32).unwrap() };
diff --git a/tests/ui/transmute_int_to_char.rs b/tests/ui/transmute_int_to_char.rs
index b24bb17..8c83ecc 100644
--- a/tests/ui/transmute_int_to_char.rs
+++ b/tests/ui/transmute_int_to_char.rs
@@ -1,5 +1,5 @@
#![warn(clippy::transmute_int_to_char)]
-#![allow(clippy::missing_transmute_annotations)]
+#![allow(clippy::missing_transmute_annotations, unnecessary_transmutes)]
fn int_to_char() {
let _: char = unsafe { std::mem::transmute(0_u32) };
diff --git a/tests/ui/transmute_int_to_char_no_std.fixed b/tests/ui/transmute_int_to_char_no_std.fixed
index e525751..e6e09a2 100644
--- a/tests/ui/transmute_int_to_char_no_std.fixed
+++ b/tests/ui/transmute_int_to_char_no_std.fixed
@@ -1,7 +1,7 @@
#![no_std]
#![feature(lang_items)]
#![warn(clippy::transmute_int_to_char)]
-#![allow(clippy::missing_transmute_annotations)]
+#![allow(clippy::missing_transmute_annotations, unnecessary_transmutes)]
use core::panic::PanicInfo;
diff --git a/tests/ui/transmute_int_to_char_no_std.rs b/tests/ui/transmute_int_to_char_no_std.rs
index 7cb508c..0f2106d 100644
--- a/tests/ui/transmute_int_to_char_no_std.rs
+++ b/tests/ui/transmute_int_to_char_no_std.rs
@@ -1,7 +1,7 @@
#![no_std]
#![feature(lang_items)]
#![warn(clippy::transmute_int_to_char)]
-#![allow(clippy::missing_transmute_annotations)]
+#![allow(clippy::missing_transmute_annotations, unnecessary_transmutes)]
use core::panic::PanicInfo;