-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: render docs from aliased type when type has no docs #18349
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
Conversation
crates/ide/src/hover/render.rs
Outdated
famous_defs: Option<&FamousDefs<'_, '_>>, | ||
edition: Edition, | ||
) -> Option<Documentation> { | ||
let mut docs = def.docs(db, famous_defs, edition); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. :(
Thanks! |
☀️ Test successful - checks-actions |
Trying to close #18344
Find the docs by traversing upwards if the type itself has none but aliasing for another type that might have.