rustdoc: Fix cosmetic issues when reporting unresolved paths in broken_intra_doc_links#156022
Open
tonywu6 wants to merge 3 commits intorust-lang:mainfrom
Open
rustdoc: Fix cosmetic issues when reporting unresolved paths in broken_intra_doc_links#156022tonywu6 wants to merge 3 commits intorust-lang:mainfrom
broken_intra_doc_links#156022tonywu6 wants to merge 3 commits intorust-lang:mainfrom
Conversation
- Add a check while trying to resolve parents, so that for links like
[`::unresolved::path`], rustdoc will say:
"no item named `unresolved` in scope"
instead of:
"no item named `` in scope"
- Update corresponding test
- Check whether an unresolved path is in fact invalid. This prevents rustdoc from emitting nonsensical diagnostics like: - "no item named `std:` in scope" - "no item named `` in scope" Instead rustdoc will now say "has invalid path separator" (the same message from `MalformedGenerics::InvalidPathSeparator`) This is done by checking whether each path segment is empty or contains extra ":" after it's been split by the path separator "::". - Add a dedicated test `tests/rustdoc-ui/intra-doc/invalid-path-separator.rs` which contains some examples of such invalid paths. Some refactoring because of this extra check: - Lift the "Check if parent of path gets resolved" logic into a closure, which I think makes the control flow more digestible. - Lift some extra diagnostic notes into a reused closure. - Some unrelated test snapshots have been updated because of this new check.
`resolution_failure` has a loop to handle possibly multiple `ResolutionFailure`s but some branches in it was returning early instead of continuing the loop. Changing them to `continue` affects no test.
Collaborator
|
rustbot has assigned @lolbinarycat. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix some minor issues with how the
rustdoc::broken_intra_doc_linkslint labels unresolved items:a469a4aFor unresolved "extern prelude" links like::unresolved::itemno item named `` in scopeno item named `unresolved` in scopeeeb96faSome malformed paths are now accounted for, for example:std:::pathno item named `std:` in scopehas invalid path separatorstd::::pathno item named `` in scopehas invalid path separatorThis PR is broken down into a few commits with their own descriptions, which I hope makes reviewing easier!