-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied
Description
Summary
title, there is also an inconsistency depending on if type annotations are used or a turbofish (see reproducer).
<*const T>::cast<U> (and the one for *mut T) does not allow an unsized U because the vtables may not be of the same type. can cast be improved to allow unsized values with the same vtable type?
Reproducer
I tried this code:
let ptr = &[1, 2, 3] as *const [i32];
let r1 = unsafe { core::mem::transmute::<*const [i32], &[u32]>(ptr) };
let r2: &[u32] = unsafe { core::mem::transmute(ptr) };I expected to see this happen:
Suggestion to use as on both.
Instead, this happened:
Clippy suggests to rewrite the first transmute as &*ptr.cast::<[u32]>().
Version
rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-unknown-linux-gnu
release: 1.81.0
LLVM version: 18.1.7
Additional Labels
@rustbot label +I-suggestion-causes-error
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied