Skip to content

Commit

Permalink
fix: the fields or variants of ADT was not restricted by limitations …
Browse files Browse the repository at this point in the history
…when hovering on Self type
  • Loading branch information
roife committed Apr 6, 2024
1 parent 4b8f51c commit 0ec41cd
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
9 changes: 9 additions & 0 deletions crates/ide/src/hover/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,15 @@ pub(super) fn definition(
Definition::Adt(adt) => {
adt.display_limited(db, config.max_adt_fields_or_variants_count).to_string()
}
Definition::SelfType(impl_def) => {
let self_ty = &impl_def.self_ty(db);
match self_ty.as_adt() {
Some(adt) => {
adt.display_limited(db, config.max_adt_fields_or_variants_count).to_string()
}
None => self_ty.display(db).to_string(),
}
}
_ => def.label(db),
};
let docs = def.docs(db, famous_defs);
Expand Down
34 changes: 31 additions & 3 deletions crates/ide/src/hover/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,28 @@ impl Thing {
test
```
```rust
struct Thing {
x: u32,
}
```
"#]],
);
check_hover_adt_fields_or_variants_limit(
None,
r#"
struct Thing { x: u32 }
impl Thing {
fn new() -> Self { Self$0 { x: 0 } }
}
"#,
expect![[r#"
*Self*
```rust
test
```
```rust
struct Thing
```
Expand All @@ -1643,7 +1665,9 @@ impl Thing {
```
```rust
struct Thing
struct Thing {
x: u32,
}
```
"#]],
);
Expand All @@ -1662,7 +1686,9 @@ impl Thing {
```
```rust
enum Thing
enum Thing {
A,
}
```
"#]],
);
Expand All @@ -1681,7 +1707,9 @@ impl Thing {
```
```rust
enum Thing
enum Thing {
A,
}
```
"#]],
);
Expand Down

0 comments on commit 0ec41cd

Please sign in to comment.