Skip to content

Conversation

dqkqd
Copy link
Contributor

@dqkqd dqkqd commented Oct 20, 2024

Trying to close #18344

  • Find the docs by traversing upwards if the type itself has none but aliasing for another type that might have.
  • Show docs from aliased type.
  • Showing description that we are displaying documentation for different definition in hover box.

image

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 20, 2024
@dqkqd dqkqd marked this pull request as ready for review October 20, 2024 11:16
@dqkqd dqkqd marked this pull request as draft October 20, 2024 22:36
@dqkqd dqkqd marked this pull request as ready for review October 21, 2024 10:41
famous_defs: Option<&FamousDefs<'_, '_>>,
edition: Edition,
) -> Option<Documentation> {
let mut docs = def.docs(db, famous_defs, edition);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should go through the HIR here instead of doing a syntactic walk, something like

if let Definition::TypeAlias(type_alias) = def {
    if docs.is_some() {
        return docs;
    }
	if let Some(adt) = type_alias.ty(db).as_adt() {
    	return adt.docs(db, famous_desf, edition);
    }
}

This means we miss intermediate aliases but that is fine, we don't handle those with most things due to how the type system erases them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I fixed it.
Should have looked at the implementation in def.docs, rather than walking syntactically. :(

@Veykril
Copy link
Member

Veykril commented Oct 22, 2024

Thanks!
@bors r+

@bors
Copy link
Contributor

bors commented Oct 22, 2024

📌 Commit 44e48d7 has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Oct 22, 2024

⌛ Testing commit 44e48d7 with merge eddab6e...

@bors
Copy link
Contributor

bors commented Oct 22, 2024

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing eddab6e to master...

@bors bors merged commit eddab6e into rust-lang:master Oct 22, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hovering a type alias should render documentation of the aliased type if it lacks docs
4 participants