-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
rustdoc: assoc const bounds from supertraits #151686
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
base: main
Are you sure you want to change the base?
Conversation
|
rustbot has assigned @GuillaumeGomez. Use |
This comment has been minimized.
This comment has been minimized.
4f2ef15 to
9f1aecd
Compare
When documenting code with associated const equality bounds where the const is defined in a supertrait, `rustdoc` would panic with "called `Option::unwrap()` on a `None` value" because it only searched for the associated item in the immediate trait. This can be fixed by adding a recursive helper function that searched through the traits supertrait hierarchy to find the associated item.
|
The job Click to see the possible cause of the failure (guessed by this bot) |
| .map(|item| item.def_id); | ||
| let assoc_item = | ||
| find_assoc_item_in_trait(cx.tcx, trait_did, constraint.ident, assoc_tag); | ||
| AssocItemConstraintKind::Equality { term: clean_hir_term(assoc_item, term, cx) } |
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.
I'm somewhat surprised that cleaning HIR terms cleans the middle representation of consts. If we didn't we wouldn't need to do all this searching (essentially mimicking rustc's HIR ty lowering in a more fragile manner).
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 could defer the const middle representation conversion until later in the pipeline? But idk if that would touch too many other parts of rustdoc
When documenting code with associated const equality bounds where the const is defined in a supertrait,
rustdocwould panic with "calledOption::unwrap()on aNonevalue" because it only searched for the associated item in the immediate trait.This can be fixed by adding a recursive helper function that searched through the traits supertrait hierarchy to find the associated item.
Fixes #151511