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

Add Item::from_def_id_and_kind to reduce duplication in rustdoc #77820

Merged
merged 4 commits into from
Nov 18, 2020

Commits on Nov 17, 2020

  1. Use DefPath for clean::Visibility, not clean::Path

    Visibility needs much less information than a full path, since modules
    can never have generics. This allows constructing a Visibility from only
    a DefId.
    
    Note that this means that paths are now normalized to their DefPath.
    In other words, `pub(self)` or `pub(super)` now always shows `pub(in
    path)` instead of preserving the original text.
    jyn514 committed Nov 17, 2020
    Configuration menu
    Copy the full SHA
    6c28ffb View commit details
    Browse the repository at this point in the history
  2. Fix broken handling of MacroDef in Map::attrs

    This also uses an exhaustive match to avoid future similar bugs.
    jyn514 committed Nov 17, 2020
    Configuration menu
    Copy the full SHA
    c9a17b1 View commit details
    Browse the repository at this point in the history
  3. Add from_def_id_and_kind reducing duplication in rustdoc

    - Add `Item::from_hir_id_and_kind` convenience wrapper
    - Make name parameter mandatory
    
      `tcx.opt_item_name` doesn't handle renames, so this is necessary
      for any item that could be renamed, which is almost all of them.
    
    - Override visibilities to be `Inherited` for enum variants
    
      `tcx.visibility` returns the effective visibility, not the visibility
      that was written in the source code. `pub enum E { A, B }` always has
      public variants `A` and `B`, so there's no sense printing `pub` again.
    
    - Don't duplicate handling of `Visibility::Crate`
    
      Instead, represent it as just another `Restricted` path.
    jyn514 committed Nov 17, 2020
    Configuration menu
    Copy the full SHA
    fc4ca55 View commit details
    Browse the repository at this point in the history
  4. Remove dead code in rustdoc::doctree

    It was completely unused.
    jyn514 committed Nov 17, 2020
    Configuration menu
    Copy the full SHA
    0e1a302 View commit details
    Browse the repository at this point in the history