mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 21:35:20 +00:00
Auto merge of #18349 - dqkqd:issue-18344, r=Veykril
feat: render docs from aliased type when type has no docs Trying to close #18344 - [x] ~Find the docs by traversing upwards if the type itself has none but aliasing for another type that might have.~ - [x] Show docs from aliased type. - [x] Showing description that we are displaying documentation for different definition in hover box. 
This commit is contained in:
commit
eddab6e98c
2 changed files with 166 additions and 1 deletions
|
@ -9018,3 +9018,156 @@ foo!(BAR_$0);
|
|||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn type_alias_without_docs() {
|
||||
// Simple.
|
||||
check(
|
||||
r#"
|
||||
/// Docs for B
|
||||
struct B;
|
||||
|
||||
type A$0 = B;
|
||||
"#,
|
||||
expect![[r#"
|
||||
*A*
|
||||
|
||||
```rust
|
||||
test
|
||||
```
|
||||
|
||||
```rust
|
||||
// size = 0, align = 1
|
||||
type A = B
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
*This is the documentation for* `struct B`
|
||||
|
||||
Docs for B
|
||||
"#]],
|
||||
);
|
||||
|
||||
// Nested.
|
||||
check(
|
||||
r#"
|
||||
/// Docs for C
|
||||
struct C;
|
||||
|
||||
type B = C;
|
||||
|
||||
type A$0 = B;
|
||||
"#,
|
||||
expect![[r#"
|
||||
*A*
|
||||
|
||||
```rust
|
||||
test
|
||||
```
|
||||
|
||||
```rust
|
||||
// size = 0, align = 1
|
||||
type A = B
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
*This is the documentation for* `struct C`
|
||||
|
||||
Docs for C
|
||||
"#]],
|
||||
);
|
||||
|
||||
// Showing the docs for aliased struct instead of intermediate type.
|
||||
check(
|
||||
r#"
|
||||
/// Docs for C
|
||||
struct C;
|
||||
|
||||
/// Docs for B
|
||||
type B = C;
|
||||
|
||||
type A$0 = B;
|
||||
"#,
|
||||
expect![[r#"
|
||||
*A*
|
||||
|
||||
```rust
|
||||
test
|
||||
```
|
||||
|
||||
```rust
|
||||
// size = 0, align = 1
|
||||
type A = B
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
*This is the documentation for* `struct C`
|
||||
|
||||
Docs for C
|
||||
"#]],
|
||||
);
|
||||
|
||||
// No docs found.
|
||||
check(
|
||||
r#"
|
||||
struct C;
|
||||
|
||||
type B = C;
|
||||
|
||||
type A$0 = B;
|
||||
"#,
|
||||
expect![[r#"
|
||||
*A*
|
||||
|
||||
```rust
|
||||
test
|
||||
```
|
||||
|
||||
```rust
|
||||
// size = 0, align = 1
|
||||
type A = B
|
||||
```
|
||||
"#]],
|
||||
);
|
||||
|
||||
// Multiple nested crate.
|
||||
check(
|
||||
r#"
|
||||
//- /lib.rs crate:c
|
||||
/// Docs for C
|
||||
pub struct C;
|
||||
|
||||
//- /lib.rs crate:b deps:c
|
||||
pub use c::C;
|
||||
pub type B = C;
|
||||
|
||||
//- /lib.rs crate:a deps:b
|
||||
pub use b::B;
|
||||
pub type A = B;
|
||||
|
||||
//- /main.rs crate:main deps:a
|
||||
use a::A$0;
|
||||
"#,
|
||||
expect![[r#"
|
||||
*A*
|
||||
|
||||
```rust
|
||||
a
|
||||
```
|
||||
|
||||
```rust
|
||||
// size = 0, align = 1
|
||||
pub type A = B
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
*This is the documentation for* `pub struct C`
|
||||
|
||||
Docs for C
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue