-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
View memory layout gives incorrect layout for unions #17091
Comments
rust-analyzer/crates/ide/src/view_memory_layout.rs Lines 119 to 133 in 46702ff
Here we're simply using |
Yes we need to check what kind of ADT we are dealing with here, ideally we'd render things differently for union showing that they overlap. Tbf, this feature needs a design overhaul, it is very hard to parse imo :) Iirc Visual Studio (not Code) has a very nice looking one, and there is an extension for vscode that has a really nice one for C++ that I can't recall the name of (might've been builtin into the clang extension) |
Might be https://marketplace.visualstudio.com/items?itemName=RamonViladomat.StructLayout. Really cool. |
rust-analyzer version: rust-analyzer version: 0.4.1830-standalone
rustc version: rustc 1.77.0 (aedd173a2 2024-03-17)
editor or extension: Code OSS (on arch linux, installed with pacman,
code 1.87.2-1
)relevant settings: None
code snippet to reproduce:
result when hitting
Ctrl+Shift+P
and going to 'view memory layout':when hovering on the
b: u32
field, the tooltip reports an offset of 0, although it is not placed at an offset of 0 in here:this is a cool feature, but it just needs some more polishing:
for example, it knows
PhantomData<T>
always has zero size, although in the tooltip it will sayA<{unknown}>
, but[T; 0]
also has zero size and for that it says 'Not Available'it does not account for fat pointers:
this will report the
&T
being 8 bytes wide (&{unknown}
here too). this is only correct ifT: Sized
and for enums just size and align is displayed, nothing is done with the members
The text was updated successfully, but these errors were encountered: