Skip to content

Commit f405b4a

Browse files
committed
fix: the fields or variants of ADT was not restricted by limitations when hovering on Self type
1 parent 4b8f51c commit f405b4a

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

Diff for: crates/ide/src/hover/render.rs

+7
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,13 @@ pub(super) fn definition(
413413
Definition::Adt(adt) => {
414414
adt.display_limited(db, config.max_adt_fields_or_variants_count).to_string()
415415
}
416+
Definition::SelfType(impl_def) => {
417+
let self_ty = &impl_def.self_ty(db);
418+
match self_ty.as_adt() {
419+
Some(adt) => adt.display_limited(db, config.max_adt_fields_or_variants_count).to_string(),
420+
None => self_ty.display(db).to_string(),
421+
}
422+
},
416423
_ => def.label(db),
417424
};
418425
let docs = def.docs(db, famous_defs);

Diff for: crates/ide/src/hover/tests.rs

+31-3
Original file line numberDiff line numberDiff line change
@@ -1623,6 +1623,28 @@ impl Thing {
16231623
test
16241624
```
16251625
1626+
```rust
1627+
struct Thing {
1628+
x: u32,
1629+
}
1630+
```
1631+
"#]],
1632+
);
1633+
check_hover_adt_fields_or_variants_limit(
1634+
None,
1635+
r#"
1636+
struct Thing { x: u32 }
1637+
impl Thing {
1638+
fn new() -> Self { Self$0 { x: 0 } }
1639+
}
1640+
"#,
1641+
expect![[r#"
1642+
*Self*
1643+
1644+
```rust
1645+
test
1646+
```
1647+
16261648
```rust
16271649
struct Thing
16281650
```
@@ -1643,7 +1665,9 @@ impl Thing {
16431665
```
16441666
16451667
```rust
1646-
struct Thing
1668+
struct Thing {
1669+
x: u32,
1670+
}
16471671
```
16481672
"#]],
16491673
);
@@ -1662,7 +1686,9 @@ impl Thing {
16621686
```
16631687
16641688
```rust
1665-
enum Thing
1689+
enum Thing {
1690+
A,
1691+
}
16661692
```
16671693
"#]],
16681694
);
@@ -1681,7 +1707,9 @@ impl Thing {
16811707
```
16821708
16831709
```rust
1684-
enum Thing
1710+
enum Thing {
1711+
A,
1712+
}
16851713
```
16861714
"#]],
16871715
);

0 commit comments

Comments
 (0)