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

Improve suggestions for broken intra-doc links #75756

Merged
merged 25 commits into from
Sep 12, 2020

Commits on Sep 5, 2020

  1. Configuration menu
    Copy the full SHA
    3797f29 View commit details
    Browse the repository at this point in the history
  2. Update .stderr

    jyn514 committed Sep 5, 2020
    Configuration menu
    Copy the full SHA
    f45e7b5 View commit details
    Browse the repository at this point in the history
  3. Use fewer .to_string()s

    jyn514 committed Sep 5, 2020
    Configuration menu
    Copy the full SHA
    4ace4e7 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    fcb2199 View commit details
    Browse the repository at this point in the history
  5. Pass on the DefId so rustdoc can name it in suggestions

    Look at this beauty:
    
    ```rust
    error: unresolved link to `S::h`
      --> intra-link-errors.rs:51:6
       |
    51 | /// [type@S::h]
       |      ^^^^^^^^^ help: to link to the associated function, use its disambiguator: `S::h()`
       |
       = note: this link resolves to the associated function `h`, which is not in the type namespace
    ```
    jyn514 committed Sep 5, 2020
    Configuration menu
    Copy the full SHA
    42bed03 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    f4e6ebd View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    002d3a9 View commit details
    Browse the repository at this point in the history
  8. Remove some TODOs

    jyn514 committed Sep 5, 2020
    Configuration menu
    Copy the full SHA
    7b8d0be View commit details
    Browse the repository at this point in the history
  9. Make errors more concise and helpful

    Before:
    ```
       = note: this link partially resolves to the struct `S`
       = note: no `fmt` in `S`
    ```
    
    After:
    ```
       = note: the struct `S` has no field or associated item named `fmt`
    ```
    jyn514 committed Sep 5, 2020
    Configuration menu
    Copy the full SHA
    e2d69f2 View commit details
    Browse the repository at this point in the history
  10. Fix failures to resolve primitives

    Previously, when looking for the associated items for primitives,
    rustdoc would look for primitives in the current namespace.
    But all primitives are in the type namespace. To fix this, rustdoc now
    always looks for primitives in the namespace when considering them as a
    stepping stone to the associated item.
    
    However, fixing that bug caused several duplicate errors because rustdoc
    now reports the same error in each namespace. To avoid this, rustdoc now
    ignores all duplicate errors when issuing them.
    jyn514 committed Sep 5, 2020
    Configuration menu
    Copy the full SHA
    19d1002 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    ebc8cb4 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    6875220 View commit details
    Browse the repository at this point in the history
  13. Give a better error message when linking to a macro with the wrong di…

    …sambiguator
    
    Before:
    
    ```
    warning: unresolved link to `m`
     --> m.rs:1:6
      |
    1 | /// [value@m]
      |      ^^^^^^^
      |
      = note: `#[warn(broken_intra_doc_links)]` on by default
      = note: no item named `m` is in scope
      = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
    ```
    
    After:
    
    ```
    warning: unresolved link to `m`
     --> m.rs:1:6
      |
    1 | /// [value@m]
      |      ^^^^^^^ help: to link to the macro, use its disambiguator: `m!`
      |
      = note: `#[warn(broken_intra_doc_links)]` on by default
      = note: this link resolves to the macro `m`, which is not in the value namespace
    ```
    jyn514 committed Sep 5, 2020
    Configuration menu
    Copy the full SHA
    418f608 View commit details
    Browse the repository at this point in the history
  14. Fix rebase conflicts

    jyn514 committed Sep 5, 2020
    Configuration menu
    Copy the full SHA
    2ca6f11 View commit details
    Browse the repository at this point in the history
  15. Address my own review comments

    - Remove unneeded lifetime parameter
    - Comment why some code doesn't use `check_full_res`
    jyn514 committed Sep 5, 2020
    Configuration menu
    Copy the full SHA
    bb9d157 View commit details
    Browse the repository at this point in the history
  16. Show the first path segment which failed to resolve.

    Before, it would arbitrarily pick the third-to-last if the last three or
    more did not resolve.
    jyn514 committed Sep 5, 2020
    Configuration menu
    Copy the full SHA
    f2826d9 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    d67eb1f View commit details
    Browse the repository at this point in the history
  18. Say 'prefix with kind@' instead of 'prefix with the item kind'

    This is both more specific and easier to read.
    jyn514 committed Sep 5, 2020
    Configuration menu
    Copy the full SHA
    ee683ef View commit details
    Browse the repository at this point in the history
  19. Give a much better error message when an item has a macro disambiguator

    Previously, this called `check_full_res` for values and types, but not
    macros. This would result in not showing when there was a partial
    resolution for a parent of the item.
    
    This now calls `check_full_res`. Additionally, it checks if there was a
    disambiguator, and if so, says that specific kind wasn't found instead
    of saying generically 'associated item'.
    jyn514 committed Sep 5, 2020
    Configuration menu
    Copy the full SHA
    efdc3fa View commit details
    Browse the repository at this point in the history
  20. x.py bless

    jyn514 committed Sep 5, 2020
    Configuration menu
    Copy the full SHA
    8318a18 View commit details
    Browse the repository at this point in the history
  21. Find the first segment that failed to resolve for _any_ namespace

    Moves this detection into `resolution_failure` to avoid doing
    unnecessary work and make the control flow a little easier to work with.
    jyn514 committed Sep 5, 2020
    Configuration menu
    Copy the full SHA
    cd72d90 View commit details
    Browse the repository at this point in the history

Commits on Sep 11, 2020

  1. box ResolutionFailures on the heap

    This decreases the size of the `Result`s being returned,
    improving performance in the common case.
    jyn514 committed Sep 11, 2020
    Configuration menu
    Copy the full SHA
    c213c68 View commit details
    Browse the repository at this point in the history
  2. Use span_label instead of note

    This puts the error message closer to the link, making it easier to see
    what went wrong.
    jyn514 committed Sep 11, 2020
    Configuration menu
    Copy the full SHA
    57250ef View commit details
    Browse the repository at this point in the history
  3. Remove unnecessary clone

    jyn514 committed Sep 11, 2020
    Configuration menu
    Copy the full SHA
    b2a5a7a View commit details
    Browse the repository at this point in the history
  4. Name the current module

    'not in scope' -> 'not in `module`'
    jyn514 committed Sep 11, 2020
    Configuration menu
    Copy the full SHA
    5ea3eaf View commit details
    Browse the repository at this point in the history