forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit d7b0b8e
committed
Cleanup intra-doc link handling of
- Remove the difference between `parent_item` and `current_item`; these
should never have been different.
- Remove `current_item` from `resolve` and `variant_field` so that
`Self` is only substituted in one place at the very start.
- Resolve the current item as a `DefId`, not a `HirId`. This allows
using `Self` across crates.
Hacks:
- `clean` uses `TypedefItem` when it _really_ should be
`AssociatedTypeItem`. I tried fixing this without success and hacked
around it instead (see comments)
- This doesn't replace `Self` if there's no parent for the current item.
In theory this should be possible, but it caused panics when I tried to
implement it.
- This replaces `Self` in the _displayed_ text, not just when resolving.
This should probably be fixed, but it was an existing issue so I didn't
fix it here.
- Use `Res` instead of strings for associated items
The main idea is to, if given a `Self` type, skip over all the logic to find the root type and go straight to resolving the associated item. Everything else is just refactors to make implementing that possible.
+ Switch to using `Res` instead of a string for `resolve_associated_item`
+ Use a `Res` instead of a string for `variant_field`
+ Remove `self_name`
+ If given a `Self` type, skip over all the logic to find the root type
and go straight to resolving the associated item
+ Give a more helpful error if there's no `Self` type in scope
+ Fix broken `all_fields()` logic - it should have been checking enum
variants instead
- Handle primitives in `resolve_associated_item`
This does _not_ fix `Self` on primitives because it doesn't have a way
to go from the `DefId` of a lang_item to the corresponding `PrimTy`.
However once that's fixed, this fix will be necessary.
- Ignore broken test for primitives
- Fix small bug with variant fields
Previously, they would be resolved as `DefKind::Variant`, and since they
resolved successfully, passed through to `resolve_associated_item`.
Then, if resolve_associated_item couldn't handle them,
it would pass `path_str` to `variant_field`.
But after my change, it no longer had access to `path_str` - all it had
was `item_str`, which is only one path segment long. So it would never
resolve through `variant_field`.
Instead, skip straight to `variant_field` if the path resolved to a variant.
- Don't resolve `variant_field` in more than one place
Now that `resolve` handles it, `resolve_associated_item` doesn't need to.
- Add test for unresolved `Self`Self
1 parent f1dab24 commit d7b0b8eCopy full SHA for d7b0b8e
File tree
4 files changed
+251
-202
lines changedFilter options
- src
- librustdoc/passes
- test
- rustdoc
- rustdoc-ui
4 files changed
+251
-202
lines changed
0 commit comments