Skip to content
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

Refactor and fix intra-doc link diagnostics, and fix links to primitives #76955

Merged
merged 3 commits into from
Sep 27, 2020

Commits on Sep 24, 2020

  1. Perform most diagnostic lookups in resolution_failure

    Previously, these were spread throughout the codebase. This had two
    drawbacks:
    
    1. It caused the fast path to be slower: even if a link resolved,
    rustdoc would still perform various lookups for the error diagnostic.
    2. It was inconsistent and didn't always give all diagnostics (rust-lang#76925)
    
    Now, diagnostics only perform expensive lookups in the error case.
    Additionally, the error handling is much more consistent, both in
    wording and behavior.
    
    - Remove `CannotHaveAssociatedItems`, `NotInScope`, `NoAssocItem`, and `NotAVariant`
      in favor of the more general `NotResolved`
    
      `resolution_failure` will now look up which of the four above
      categories is relevant, instead of requiring the rest of the code to
      be consistent and accurate in which it picked.
    
    - Remove unnecessary lookups throughout the intra-doc link pass. These
    are now done by `resolution_failure`.
      + Remove unnecessary `extra_fragment` argument to `variant_field()`;
        it was only used to do lookups on failure.
      + Remove various lookups related to associated items
      + Remove distinction between 'not in scope' and 'no associated item'
    
    - Don't perform unnecessary copies
    - Remove unused variables and code
    - Update tests
    - Note why looking at other namespaces is still necessary
    - 'has no inner item' -> 'contains no item'
    
    bless tests
    jyn514 committed Sep 24, 2020
    Configuration menu
    Copy the full SHA
    dd7b8c8 View commit details
    Browse the repository at this point in the history
  2. Fix intra-doc links for primitives

    - Add `PrimTy::name` and `PrimTy::name_str`
    - Use those new functions to distinguish between the name in scope and
    the canonical name
    - Fix diagnostics for primitive types
    - Add tests for primitives
    jyn514 committed Sep 24, 2020
    Configuration menu
    Copy the full SHA
    472e52e View commit details
    Browse the repository at this point in the history
  3. Unify primitive errors with other intra-link errors

    Now that `PrimTy::name()` exists, there's no need to carry around the
    name of the primitive that failed to resolve. This removes the variants
    special-casing primitives in favor of `NotResolved`.
    
    - Remove `NoPrimitiveImpl` and `NoPrimitiveAssocItem`
    - Remove hacky `has_primitive` check in `resolution_failure()`
    - Fixup a couple tests that I forgot to `--bless` before
    jyn514 committed Sep 24, 2020
    Configuration menu
    Copy the full SHA
    049d29b View commit details
    Browse the repository at this point in the history