Skip to content

Commit ad7fc4f

Browse files
authored
Fix missing_transmute_annotations example (#16024)
The "bad" example in the `missing_transmute_annotations` example didn't actually trigger the lint and so wasn't a "bad" example. This PR replaces it with an actual "bad" example. It was discussed on zulip [here](https://rust-lang.zulipchat.com/#narrow/channel/257328-clippy/topic/missing_transmute_annotations/near/547657390). changelog: Fix `missing_transmute_annotations` example r? @Centri3
2 parents a456519 + 0afbb65 commit ad7fc4f

File tree

1 file changed

+4
-3
lines changed
  • clippy_lints/src/transmute

1 file changed

+4
-3
lines changed

clippy_lints/src/transmute/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,10 +435,11 @@ declare_clippy_lint! {
435435
/// to infer a technically correct yet unexpected type.
436436
///
437437
/// ### Example
438-
/// ```no_run
438+
/// ```
439439
/// # unsafe {
440+
/// let mut x: i32 = 0;
440441
/// // Avoid "naked" calls to `transmute()`!
441-
/// let x: i32 = std::mem::transmute([1u16, 2u16]);
442+
/// x = std::mem::transmute([1u16, 2u16]);
442443
///
443444
/// // `first_answers` is intended to transmute a slice of bool to a slice of u8.
444445
/// // But the programmer forgot to index the first element of the outer slice,
@@ -449,7 +450,7 @@ declare_clippy_lint! {
449450
/// # }
450451
/// ```
451452
/// Use instead:
452-
/// ```no_run
453+
/// ```
453454
/// # unsafe {
454455
/// let x = std::mem::transmute::<[u16; 2], i32>([1u16, 2u16]);
455456
///

0 commit comments

Comments
 (0)