summary refs log tree commit diff
path: root/src/librustdoc/clean
AgeCommit message (Collapse)AuthorLines
2021-11-26Rename `Type::ResolvedPath` to `Type::Path`Noah Lev-9/+10
At last! The new name is shorter, simpler, and consistent with `hir::Ty`.
2021-11-25Stop re-exporting `Type::ResolvedPath`Noah Lev-12/+10
I would like to rename it to `Type::Path`, but then it can't be re-exported since the name would conflict with the `Path` struct. Usually enum variants are referred to using their qualified names in Rust (and parts of rustdoc already do that with `clean::Type`), so this is also more consistent with the language.
2021-11-25Clean up `clean` re-exportsNoah Lev-10/+8
This will allow re-exporting only certain enum variants.
2021-11-24Update commentNoah Lev-1/+1
Co-authored-by: Joshua Nelson <github@jyn.dev>
2021-11-24Remove `ResolvedPath.did`Noah Lev-7/+8
2021-11-24Use `path.def_id()` in `Type::inner_def_id()`Noah Lev-1/+1
2021-11-24Return the actual `DefId` for assoc. items in `register_res`Noah Lev-10/+2
Before, if `register_res` were called on an associated item or enum variant, it would return the parent's `DefId`. Now, it returns the actual `DefId`. This change is a step toward removing `Type::ResolvedPath.did` and potentially removing `kind_side_channel` in rustdoc. It also just simplifies rustdoc's behavior.
2021-11-23Auto merge of #91094 - inquisitivecrystal:rustdoc-top-mod, r=jyn514bors-2/+13
Avoid documenting top-level private imports PR #88447 aimed to make rustdoc's `--document-private-items` mode only document imports that are visible outside the importing module. Unfortunately, I inadvertently set things up so that imports at the crate top-level are always documented, regardless of their visibility. This behavior was unintended and is [not desirable](https://github.com/rust-lang/rust/issues/90865#issuecomment-971172649). This PR treats top-level imports as never being visible outside their parent module. In practice, the only way a top-level import can be visible externally is if it's fully public, and there's a seperate check for that. It's worth calling attention to the fact that this change means that `pub(crate)` imports will be visible in lower level modules, but not at the top-level. This is because, at the top level of the crate, `pub(crate)` means the same thing as `pub(self)`. It turned out that there were existing tests checking for the only behavior, which I didn't notice at the time of my previous PR. I have updated them to check for the new behavior and substantially extended them to handle differences between the top-level module and lower level modules. I may have gone overboard, so please tell me if there's anything I should cut. r? `@jyn514` Fixes #90865.
2021-11-21Auto merge of #90844 - camelid:cleanup-vis, r=jyn514bors-74/+41
rustdoc: Finish transition to computed visibility This finishes the transition to using computed visibility in rustdoc.
2021-11-21Auto merge of #91073 - camelid:small-cleanups, r=jyn514bors-4/+8
rustdoc: Make two small cleanups
2021-11-20Auto merge of #91066 - camelid:externs, r=jyn514,GuillaumeGomezbors-13/+3
rustdoc: Remove `Crate.externs` and compute on-demand instead r? `@GuillaumeGomez` cc `@jyn514`
2021-11-19rustdoc: Move doc-reachability visiting back to cleaningNoah Lev-0/+6
It populates `cx.cache.access_levels`, which seems to be needed during cleaning since a bunch of tests are failing.
2021-11-19rustdoc: Record aliases as SymbolsNoah Lev-4/+4
2021-11-19rustdoc: Add static size assertion for DocFragmentNoah Lev-0/+4
Tons of them are constructed, so the size has a big impact on max-rss.
2021-11-19rustdoc: Remove `Crate.externs` and compute on-demand insteadNoah Lev-18/+2
2021-11-18rustdoc: Remove unused `DocFragment.line` fieldNoah Lev-5/+0
2021-11-19Rollup merge of #91002 - petrochenkov:nosynth, r=davidtwcoYuki Okushi-19/+6
rustc: Remove `#[rustc_synthetic]` This function parameter attribute was introduced in https://github.com/rust-lang/rust/pull/44866 as an intermediate step in implementing `impl Trait`, it's not necessary or used anywhere by itself. Noticed while reviewing https://github.com/rust-lang/rust/pull/90947.
2021-11-19Rollup merge of #90750 - camelid:rm-tuple-impls-1, r=jyn514Yuki Okushi-18/+33
rustdoc: Replace where-bounded Clean impl with simple function This is the first step in removing the Clean impls for tuples. Either way, this significantly simplifies the code since it reduces the amount of "trait magic". (To clarify, I'm referring to impls like `impl Clean for (A, B)`, not Clean impls that work on tuples in the user's program.) cc ``@jyn514``
2021-11-18rustc: Remove `#[rustc_synthetic]`Vadim Petrochenkov-19/+6
This function parameter attribute was introduced in https://github.com/rust-lang/rust/pull/44866 as an intermediate step in implementing `impl Trait`, it's not necessary or used anywhere by itself.
2021-11-17rustdoc: Cleanup visibility cleaning some moreNoah Lev-52/+31
* Remove outdated comment * Remove duplicated code * Extract helper function
2021-11-17rustdoc: Remove Clean impl for `hir::Visibility`Noah Lev-26/+18
This should be the last bit of the transition to computed visibility, rather than syntactic visibility.
2021-11-17rustdoc: Clean `Visibility` outside of `display_macro_source`Noah Lev-13/+9
This change should make the code a bit clearer and easier to change.
2021-11-16Avoid documenting top-level private importsinquisitivecrystal-2/+13
2021-11-13Delete rustdoc::doctreehi-rustin-2/+2
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-11-09Add comments ensuring that generics are cleaned before argsNoah Lev-0/+5
Otherwise, rustdoc panics with messages like this: thread 'rustc' panicked at 'assertion failed: cx.impl_trait_bounds.is_empty()', src/librustdoc/clean/utils.rs:462:5 This ordering requirement is unrelated to the `clean_fn_decl_with_args` refactoring, but the requirement was uncovered as part of that change. I'm not sure if *all* of these places have the requirement, but I added comments to them just in case.
2021-11-09Remove unnecessary reborrowsNoah Lev-2/+5
2021-11-09Remove where bound from `clean_fn_decl_with_args`Noah Lev-16/+19
Basically, this entails moving the arguments cleaning to the call site. I extracted several local variables because: 1. It makes the code easier to read and understand. 2. If I hadn't, the extra `clean()` calls would have caused complicated tuples to be split across several lines. 3. I couldn't just extract local variables for `args` because then the arguments would be cleaned *before* the generics, while rustdoc expects them to be cleaned *after*. Only extracting `args` caused panics like this: thread 'rustc' panicked at 'assertion failed: cx.impl_trait_bounds.is_empty()', src/librustdoc/clean/utils.rs:462:5 Extracting variables makes the control flow -- and the required order of cleaning -- more explicit.
2021-11-09Use computed visibility in rustdocinquisitivecrystal-6/+10
2021-11-09Add `ty::Visibility::is_public()`inquisitivecrystal-2/+2
2021-11-09Replace where-bounded Clean impl with functionNoah Lev-13/+17
This was the only Clean impl I found with `where` bounds. This impl was doubly-confusing: it was implemented on a tuple and it was polymorphic. Combined, this caused a "spooky action at a distance" effect to make the code very confusing.
2021-11-09Rollup merge of #89561 - nbdd0121:const_typeck, r=nikomatsakisMatthias Krüger-2/+3
Type inference for inline consts Fixes #78132 Fixes #78174 Fixes #81857 Fixes #89964 Perform type checking/inference of inline consts in the same context as the outer def, similar to what is currently done to closure. Doing so would require `closure_base_def_id` of the inline const to return the outer def, and since `closure_base_def_id` can be called on non-local crate (and thus have no HIR available), a new `DefKind` is created for inline consts. The type of the generated anon const can capture lifetime of outer def, so we couldn't just use the typeck result as the type of the inline const's def. Closure has a similar issue, and it uses extra type params `CK, CS, U` to capture closure kind, input/output signature and upvars. I use a similar approach for inline consts, letting it have an extra type param `R`, and then `typeof(InlineConst<[paremt generics], R>)` would just be `R`. In borrowck region requirements are also propagated to the outer MIR body just like it's currently done for closure. With this PR, inline consts in expression position are quitely usable now; however the usage in pattern position is still incomplete -- since those does not remain in the MIR borrowck couldn't verify the lifetime there. I have left an ignored test as a FIXME. Some disucssions can be found on [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/inline.20consts.20typeck). cc `````@spastorino````` `````@lcnr````` r? `````@nikomatsakis````` `````@rustbot````` label A-inference F-inline_const T-compiler
2021-11-08Auto merge of #90443 - camelid:rustdoc-subst, r=GuillaumeGomezbors-93/+124
Merge `DocContext.{ty,lt,ct}_substs` into one map It should be impossible to have more than one entry with a particular key across the three maps, so they should be one map. In addition to making it impossible for multiple entries to exist, this should improve memory usage since now only one map is allocated on the stack and heap. r? `@GuillaumeGomez`
2021-11-07rustdoc: Remove top-level wrappers for `ImplKind` methodsNoah Lev-12/+0
The `ImplKind` methods can just be used directly instead.
2021-11-07Remove Clean impl for `&T`Noah Lev-7/+1
2021-11-07Remove unused Clean impl for `Rc<T>`Noah Lev-7/+0
2021-11-07Remove Clean impl for `Vec<T>`Noah Lev-49/+47
2021-11-07Remove Clean impl for `IndexVec<T>`Noah Lev-8/+1
2021-11-07Remove Clean impl for `Option<T>`Noah Lev-11/+5
2021-11-07rustdoc: Use `ty::ImplPolarity` instead of custom enumNoah Lev-25/+6
2021-11-07Use an enum to record polarity in `clean::Impl`Noah Lev-13/+20
2021-11-07rustdoc: Refactor `Impl.{synthetic,blanket_impl}` into enumNoah Lev-13/+46
This change has two advantages: 1. It makes the possible states clearer, and it makes it impossible to construct invalid states, such as a blanket impl that is also an auto trait impl. 2. It shrinks the size of `Impl` a bit, since now there is only one field, rather than two.
2021-11-06rustdoc: Remove redundant `Impl.span` fieldNoah Lev-11/+13
It can be computed on-demand in `Item::span()`.
2021-11-07Give inline const separate DefKindGary Guo-2/+3
2021-11-05rustdoc: clippy::complexity fixesMatthias Krüger-4/+3
2021-11-02Split doc_cfg and doc_auto_cfg featuresGuillaume Gomez-3/+6
2021-10-31Merge `DocContext.{ty,lt,ct}_substs` into one mapNoah Lev-10/+38
It should be impossible to have more than one entry with a particular key across the three maps, so they should be one map. In addition to making it impossible for multiple entries to exist, this should improve memory usage since now only one map is allocated on the stack and heap.
2021-10-31Reduce rightward driftNoah Lev-78/+74
2021-10-31Extract function for expanding private type aliasesNoah Lev-91/+98
2021-10-30rustdoc: Stop sorting external cratesNoah Lev-2/+1
Now that #73423 is fixed, sorting should no longer be necessary. See also this discussion [1]. [1]: https://github.com/rust-lang/rust/pull/86889#discussion_r664134963
2021-10-30rustdoc: Remove `Crate.name` and instead compute it on-demandNoah Lev-3/+4
It is not as large as `Crate.src` was, but it's still 8 bytes, and `clean::Crate` is moved by-value a lot.