Skip to content

Hovering a type alias should render documentation of the aliased type if it lacks docs #18344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Veykril opened this issue Oct 19, 2024 · 9 comments · Fixed by #18349
Closed
Assignees
Labels
A-hover hover feature A-ide general IDE features C-feature Category: feature request

Comments

@Veykril
Copy link
Member

Veykril commented Oct 19, 2024

/// Docs for S
struct S;

type T = S;

Hovering T should yield the Docs for S documentation.

@Veykril Veykril added A-ide general IDE features C-feature Category: feature request labels Oct 19, 2024
@lnicola lnicola added the A-hover hover feature label Oct 19, 2024
@dqkqd
Copy link
Contributor

dqkqd commented Oct 20, 2024

@rustbot claim

@ChayimFriedman2
Copy link
Contributor

I wonder if we should also show the signature of the aliased item, or only its docs. E.g. the docs may refer to its name or type parameters which don't exist in the alias.

@dqkqd
Copy link
Contributor

dqkqd commented Oct 20, 2024

@ChayimFriedman2
Oh, I had oversimplified this, thinking just traversing upwards to find the docs would be sufficient.

So, in the snippet below, we should show Docs for A instead of Docs for B when hovering to A.

/// Docs for [`B`]
struct B;

type A = B;

By showing type aliases for type parameters, I think we should just keep as is, to avoid showing u32 instead of T in the docs for Box?

type A = Box<u32>

@dqkqd
Copy link
Contributor

dqkqd commented Oct 20, 2024

Well, I found it rather hard if we need to rename the aliased type in the docs. Seem relate to #8242.

@ChayimFriedman2
Copy link
Contributor

I don't think it's possible to rename the docs. Not every usage is a link, while not every same text is a reference, and modifying only some of the usages will be very confusing.

@dqkqd
Copy link
Contributor

dqkqd commented Oct 20, 2024

Sorry, I was misreading, I not familiar with the internal and the language yet.

So, we should just show the Docs for B here (maybe with the pub struct B) without pub type A = B ?

Image

@ChayimFriedman2
Copy link
Contributor

No, we should definitely include pub type A = B. My question was whether we also need to include pub struct B.

@Veykril
Copy link
Member Author

Veykril commented Oct 20, 2024

Why rename things? Just render the docs of the aliased thing, no need to overcomplicate this (and maybe indicate that its the docs from a different item)

@dqkqd
Copy link
Contributor

dqkqd commented Oct 20, 2024

Thank you, I'll try implementing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-hover hover feature A-ide general IDE features C-feature Category: feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants