about summary refs log tree commit diff
path: root/src/librustdoc/passes
AgeCommit message (Collapse)AuthorLines
2021-12-15Remove `SymbolStr`.Nicholas Nethercote-2/+2
By changing `as_str()` to take `&self` instead of `self`, we can just return `&str`. We're still lying about lifetimes, but it's a smaller lie than before, where `SymbolStr` contained a (fake) `&'static str`!
2021-12-14fix clippy::single_char_pattern perf findingsMatthias Krüger-1/+1
2021-11-19Use fast comparison against `kw::Empty`Noah Lev-1/+3
We think `.as_str().lines().next().is_none()` should be equivalent to `== kw::Empty`. Co-authored-by: Joshua Nelson <github@jyn.dev>
2021-11-18rustdoc: Avoid using `Iterator::count()` where possibleNoah Lev-1/+1
`count()` iterates over the whole collection. Using `len()` instead, or `.next().is_none()` when comparing to zero, should be faster.
2021-11-18rustdoc: Remove unused `DocFragment.line` fieldNoah Lev-1/+0
2021-11-13Auto merge of #90385 - mfrw:mfrw/librustdoc, r=GuillaumeGomezbors-3/+4
rustdoc: use Type::def_id() instead of Type::def_id_no_primitives() For: #90187 r? `@jyn514`
2021-11-11Auto merge of #90489 - jyn514:load-all-extern-crates, r=petrochenkovbors-4/+27
rustdoc: Go back to loading all external crates unconditionally This *continues* to cause regressions. This code will be unnecessary once access to the resolver happens fully before creating the tyctxt (#83761), so load all crates unconditionally for now. To minimize churn, this leaves in the code for loading crates selectively. "Fixes" https://github.com/rust-lang/rust/issues/84738. Previously: https://github.com/rust-lang/rust/pull/83738, https://github.com/rust-lang/rust/pull/85749, https://github.com/rust-lang/rust/pull/88215 r? `@petrochenkov` cc `@camelid` (this should fix the "index out of bounds" error you had while looking up `crate_name`).
2021-11-09Rollup merge of #89561 - nbdd0121:const_typeck, r=nikomatsakisMatthias Krüger-1/+2
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-08Add more missing methods to `IntraLinkCrateLoader`Joshua Nelson-4/+27
This helps with (but does not fix) https://github.com/rust-lang/rust/issues/84738. I tested on https://github.com/jyn514/objr/commit/edcee7b8124abf0e4c63873e8422ff81beb11ebb and still hit ICEs.
2021-11-07rustdoc: Refactor `Impl.{synthetic,blanket_impl}` into enumNoah Lev-2/+2
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-07Give inline const separate DefKindGary Guo-1/+2
2021-11-05rustdoc: use Type::def_id() instead of Type::def_id_no_primitives()Muhammad Falak R Wani-3/+4
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
2021-11-01List all cases explicitly in `Doc{Folder,Visitor}`Noah Lev-2/+5
2021-10-31Convert more impls of `DocFolder` to `DocVisitor`Noah Lev-27/+26
I think these are the last of the impls that can be easily converted to visitors.
2021-10-31Convert many impls of `DocFolder` to `DocVisitor`Noah Lev-38/+39
Many of `DocFolder`'s impls didn't actually transform the syntax tree, so they can be visitors instead.
2021-10-30Rollup merge of #90183 - GuillaumeGomez:recurse-deref, r=jyn514Guillaume Gomez-9/+43
Show all Deref implementations recursively Fixes #87783. This is a re-implementation of #80653, so taking the original PR comment: This changes `rustdoc` to recursively follow `Deref` targets so that methods from all levels are added to the rendered output. This implementation displays the methods from all levels in the expanded state with separate sections for each level. ![image](https://user-images.githubusercontent.com/279572/103482863-46723b00-4ddb-11eb-972b-c463351a425c.png) cc `@camelid` r? `@jyn514`
2021-10-29Fix panic when documenting libproc-macroGuillaume Gomez-13/+10
2021-10-29Add tests for recursive derefGuillaume Gomez-4/+7
2021-10-29Recursively document DerefGuillaume Gomez-1/+35
2021-10-27Improve perf measurements of `build_extern_trait_impl`Noah Lev-3/+1
Before, it was only measuring one callsite of `build_impl`, and it incremented the call count even if `build_impl` returned early because the `did` was already inlined. Now, it measures all calls, minus calls that return early.
2021-10-27Rollup merge of #90154 - camelid:remove-getdefid, r=jyn514Matthias Krüger-5/+5
rustdoc: Remove `GetDefId` See the individual commit messages for details. r? `@jyn514`
2021-10-25Fix clippy lints in librustdocGuillaume Gomez-21/+20
2021-10-22Rename `Type::def_id_full()` to `Type::def_id()`Noah Lev-1/+1
It should be preferred over `def_id_no_primitives()`, so it should have a shorter name. I also put it before `def_id_no_primitives()` so that it shows up first in the docs.
2021-10-22Rename `Type::def_id()` to `Type::def_id_no_primitives()`Noah Lev-3/+3
The old name was confusing because it's easy to assume that using `def_id()` is fine, but in some situations it's incorrect. In general, `def_id_full()` should be preferred, so `def_id_full()` should have a shorter name. That will happen in the next commit.
2021-10-22Use `def_id_full()` where easily possibleNoah Lev-1/+1
In general, it should be preferred over `Type::def_id()`. See each method's docs for more.
2021-10-22Replace `GetDefId` with inherent methodsNoah Lev-1/+1
Now that it's only implemented for `Type`, using inherent methods instead means that imports are no longer necessary. Also, `GetDefId` is only meant to be used with `Type`, so it shouldn't be a trait.
2021-10-09Auto merge of #88379 - camelid:cleanup-clean, r=jyn514bors-3/+7
rustdoc: Cleanup various `clean` types Cleanup various `clean` types.
2021-10-04Rollup merge of #89474 - camelid:better-pass-name, r=jyn514Jubilee-14/+14
rustdoc: Improve doctest pass's name and module's name As the docs at the top of the file say, it is an overloaded pass and actually runs two lints.
2021-10-02Replace all uses of `path.res.def_id()` with `path.def_id()`Noah Lev-1/+1
2021-10-02rustdoc: Improve doctest pass's name and module's nameNoah Lev-14/+14
As the docs at the top of the file say, it is an overloaded pass and actually runs two lints.
2021-10-01rustdoc: use slice::contains instead of open-coding itMichael Howell-2/+2
2021-09-30Remove temporary `GetDefId` impl for `Path`Noah Lev-2/+4
2021-09-30Make `Impl.trait_` a `Path`, not a `Type`Noah Lev-1/+3
It should only ever be a `ResolvedPath`, so this (a) enforces that, and (b) reduces the size of `Impl`. I had to update a test because the order of the rendered auto trait impl bounds changed. I think the order changed because rustdoc sorts auto trait bounds using their `Debug` output.
2021-09-28Auto merge of #89277 - jyn514:codeblock-edition, r=GuillaumeGomezbors-4/+14
Use the correct edition for syntax highlighting doctests Previously it would unconditionally use edition 2015, which was incorrect. Helps with https://github.com/rust-lang/rust/issues/89135 in that you can now override the doctest to be 2018 edition instead of being forced to fix the error. This doesn't resolve any of the deeper problems that rustdoc disagrees with most rust users on what a code block is. cc `@Mark-Simulacrum`
2021-09-26Use the correct edition when syntax highlighting doctestsJoshua Nelson-2/+12
Previously it would unconditionally use edition 2015, which was incorrect.
2021-09-26Preserve the whole LangSyntax when parsing doctestsJoshua Nelson-2/+2
Previously, only the raw string and the `is_ignore` field were preserved, which made it hard to recover anything else.
2021-09-25Rollup merge of #88895 - camelid:cleanup-pt2, r=jyn514Manish Goregaokar-1/+1
rustdoc: Cleanup `clean` part 2 Split out from #88379. This contains the following commits from that PR: - Remove `Type::ResolvedPath.is_generic` - Rename `is_generic()` to `is_assoc_ty()` r? `@jyn514`
2021-09-24resolve: Refactor obtaining `Module` from its `DefId`Vadim Petrochenkov-1/+1
The `Option<Module>` version is supported for the case where we don't know whether the `DefId` refers to a module or not. Non-local traits and enums are also correctly found now.
2021-09-21Revert the rustdoc box syntax removalest31-1/+1
It turned out to cause (minor) perf regressions.
2021-09-17Don't lint about missing code examples in derived traitsHans-0/+1
Fixes #81775
2021-09-13Auto merge of #87915 - estebank:fancy-spans, r=oli-obkbors-2/+2
Use smaller spans for some structured suggestions Use more accurate suggestion spans for * argument parse error * fully qualified path * missing code block type * numeric casts
2021-09-13Auto merge of #88745 - hnj2:allow-trait-impl-missing-code, r=GuillaumeGomezbors-0/+20
Allow missing code examples in trait impls. Excludes Trait implementations from the items that need to have doc code examples when using the `rustdoc::missing_doc_code_examples` lint. For details see #88741 fixes #88741 r? `@jyn514`
2021-09-12Rename `is_generic()` to `is_assoc_ty()`Noah Lev-1/+1
The new name is more accurate than the previous one.
2021-09-12Fix broken handling of primitive itemsJoshua Nelson-36/+23
- Fix broken handling of primitive associated items - Remove fragment hack Fixes 83083 - more logging - Update CrateNum hacks The CrateNum has no relation to where in the dependency tree the crate is, only when it's loaded. Explicitly special-case core instead of assuming it will be the first DefId. - Update and add tests - Cache calculation of primitive locations This could possibly be avoided by passing a Cache into collect_intra_doc_links; but that's a much larger change, and doesn't seem valuable other than for this.
2021-09-11don't clone types that are Copy (clippy::clone_on_copy)Matthias Krüger-1/+1
2021-09-10Rollup merge of #88720 - GuillaumeGomez:rustdoc-coverage-fields-count, ↵Manish Goregaokar-3/+37
r=Manishearth Rustdoc coverage fields count Follow-up of #88688. Instead of requiring enum tuple variant fields and tuple struct fields to be documented, we count them if they are documented, otherwise we don't include them in the count. r? `@Manishearth`
2021-09-10Don't require documentation for fields in an enum tuple variant or for tuple ↵Guillaume Gomez-3/+37
struct fields.
2021-09-09Allow missing code examples in trait impls.Hans Niklas Jacob-0/+20
2021-09-03Use `summary_opts()` for Markdown summariesNoah Lev-4/+4
It was accidentally changed to use `opts()` in #86451. I also renamed `opts()` to `main_body_opts()` to make this kind of accidental change less likely.
2021-08-31Rollup merge of #88391 - GuillaumeGomez:fix-json-enum-variant, ↵Mara Bos-2/+2
r=camelid,notriddle Fix json tuple struct enum variant Fixes #87887. cc `@dsherret` `@camelid` r? `@notriddle`