Auto merge of #14748 - lumenian:type-alias-layout, r=HKalbasi
Show type alias layout This PR expands on #13490 to allow displaying layout data on hover for type aliases.
This commit is contained in:
commit
a10fd83120
@ -473,7 +473,10 @@ pub(super) fn definition(
|
|||||||
}),
|
}),
|
||||||
Definition::Trait(it) => label_and_docs(db, it),
|
Definition::Trait(it) => label_and_docs(db, it),
|
||||||
Definition::TraitAlias(it) => label_and_docs(db, it),
|
Definition::TraitAlias(it) => label_and_docs(db, it),
|
||||||
Definition::TypeAlias(it) => label_and_docs(db, it),
|
Definition::TypeAlias(it) => label_and_layout_info_and_docs(db, it, |&it| {
|
||||||
|
let layout = it.ty(db).layout(db).ok()?;
|
||||||
|
Some(format!("size = {}, align = {}", layout.size.bytes(), layout.align.abi.bytes()))
|
||||||
|
}),
|
||||||
Definition::BuiltinType(it) => {
|
Definition::BuiltinType(it) => {
|
||||||
return famous_defs
|
return famous_defs
|
||||||
.and_then(|fd| builtin(fd, it))
|
.and_then(|fd| builtin(fd, it))
|
||||||
|
@ -1405,7 +1405,7 @@ fn test_hover_function_pointer_show_identifiers() {
|
|||||||
```
|
```
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
type foo = fn(a: i32, b: i32) -> i32
|
type foo = fn(a: i32, b: i32) -> i32 // size = 8, align = 8
|
||||||
```
|
```
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
@ -1423,7 +1423,7 @@ fn test_hover_function_pointer_no_identifier() {
|
|||||||
```
|
```
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
type foo = fn(i32, i32) -> i32
|
type foo = fn(i32, i32) -> i32 // size = 8, align = 8
|
||||||
```
|
```
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
@ -3555,7 +3555,7 @@ fn hover_const_generic_type_alias() {
|
|||||||
```
|
```
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
type Foo2 = Foo<2>
|
type Foo2 = Foo<2> // size = 0, align = 1
|
||||||
```
|
```
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user