Closed
Description
rust-analyzer version: rust-analyzer 1.83.0
via rust-analyzer-1.83.0-1.fc41.x86_64
rustc version: rustc 1.83.0 (90b35a623 2024-11-26) (Fedora 1.83.0-1.fc41)
via rust-1.83.0-1.fc41.x86_64
editor or extension: nvim from Fedora 41: neovim-0.10.2-1.fc41.x86_64
relevant settings:
LSP configs active in this buffer (bufnr: 1) ~
- Language client log: ~/.local/state/nvim/lsp.log
- Detected filetype: `rust`
- 1 client(s) attached to this buffer
- Client: `rust_analyzer` (id: 1, bufnr: [1])
root directory: ~/src/reproducer/
filetypes: rust
cmd: /usr/local/bin/rust-analyzer
version: `rust-analyzer 1.85.0-nightly (d4025ee 2024-12-12)`
executable: true
autostart: true
code snippet to reproduce:
// add your code here
use zerocopy::KnownLayout;
#[derive(KnownLayout)]
#[repr(C)]
struct Flexible {
header: u32,
body: [u8],
}
This gets you
1. casting `*mut _` as `*mut __ZerocopyKnownLayoutMaybeUninit` is invalid: vtable kinds may not match [E0606]
2. casting `*mut __ZerocopyKnownLayoutMaybeUninit` as `*mut _` is invalid: vtable kinds may not match [E0606]
but with cargo build
it's fine.
This is caused by Flexible being a DST (dynamically sized type). Dropping the variable-sized body: [u8]
field makes the problem go away.
I also tried with nightly (rust-analyzer 1.85.0-nightly (d4025ee 2024-12-12)
) without improvement.