mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Auto merge of #13490 - HKalbasi:layout, r=jonas-schievink
Compute data layout of types cc #4091 Things that aren't working: * Closures * Generators (so no support for `Future` I think) * Opaque types * Type alias and associated types which may need normalization Things that show wrong result: * ~Enums with explicit discriminant~ * SIMD types * ~`NonZero*` and similar standard library items which control layout with special attributes~ At the user level, I didn't put much work, since I wasn't confident about what is the best way to present this information. Currently it shows size and align for ADTs, and size, align, offset for struct fields, in the hover, similar to clangd. I used it some days and I feel I liked it, but we may consider it too noisy and move it to an assist or command.
This commit is contained in:
commit
6e8a54d0f6
21 changed files with 1112 additions and 164 deletions
|
@ -30,6 +30,7 @@
|
|||
//! index: sized
|
||||
//! iterator: option
|
||||
//! iterators: iterator, fn
|
||||
//! non_zero:
|
||||
//! option:
|
||||
//! ord: eq, option
|
||||
//! pin:
|
||||
|
@ -704,6 +705,15 @@ mod macros {
|
|||
}
|
||||
// endregion:derive
|
||||
|
||||
// region:non_zero
|
||||
pub mod num {
|
||||
#[repr(transparent)]
|
||||
#[rustc_layout_scalar_valid_range_start(1)]
|
||||
#[rustc_nonnull_optimization_guaranteed]
|
||||
pub struct NonZeroU8(u8);
|
||||
}
|
||||
// endregion:non_zero
|
||||
|
||||
// region:bool_impl
|
||||
#[lang = "bool"]
|
||||
impl bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue