Don't unnecessarily suggest unsafe block
This commit is contained in:
parent
7a80c23f83
commit
11045f94e2
@ -41,7 +41,7 @@ pub(super) fn check<'tcx>(
|
||||
&format!("transmute from a `{}` to a `{}`", from_ty, to_ty),
|
||||
"consider using",
|
||||
if const_context {
|
||||
format!("unsafe {{ std::str::from_utf8_unchecked{postfix}({snippet}) }}")
|
||||
format!("std::str::from_utf8_unchecked{postfix}({snippet})")
|
||||
} else {
|
||||
format!("std::str::from_utf8{postfix}({snippet}).unwrap()")
|
||||
},
|
||||
|
@ -244,7 +244,7 @@ error: transmute from a `&[u8]` to a `&str`
|
||||
--> $DIR/transmute.rs:142:30
|
||||
|
|
||||
LL | const _: &str = unsafe { std::mem::transmute(B) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `unsafe { std::str::from_utf8_unchecked(B) }`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8_unchecked(B)`
|
||||
|
||||
error: aborting due to 39 previous errors
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user