Commit graph

192 commits

Author SHA1 Message Date
David Tolnay
0904614751
Render more readable macro matchers in rustdoc 2022-01-18 11:13:29 -08:00
Ellen
71bbb603f4 initial revert 2022-01-15 01:16:55 +00:00
Matthias Krüger
ac81a13640
Rollup merge of #92334 - dtolnay:rustdocmatcher, r=camelid,GuillaumeGomez
rustdoc: Preserve rendering of macro_rules matchers when possible

Fixes #92331. This approach restores the behavior prior to #86282 **if** the matcher token held by the compiler **and** the matcher token found in the source code are identical TokenTrees. Thus #86208 remains fixed, but without regressing formatting for the vast majority of macros which are not macro-generated.
2022-01-13 08:11:22 +01:00
Vadim Petrochenkov
5acd1f91a0 rustdoc: Introduce a resolver cache for sharing data between early doc link resolution and later passes 2022-01-07 16:21:53 +08:00
bors
b5da80871d Auto merge of #92395 - Kobzol:rustdoc-bindings-thin-vec, r=camelid
Rustdoc: use ThinVec for GenericArgs bindings

The bindings are almost always empty. This reduces the size of `PathSegment` and `GenericArgs` by about one fourth.
2022-01-03 03:49:01 +00:00
Jakub Beránek
3d8d3f1435
Rustdoc: use ThinVec for GenericArgs bindings 2022-01-01 11:29:14 +01:00
Michael Goulet
bc7968f961 remove in_band_lifetimes from librustdoc 2021-12-28 18:18:00 -08:00
David Tolnay
544a6bb7e7
Replace &DocCtxt -> TyCtxt in macro matcher rendering 2021-12-28 13:43:08 -08:00
David Tolnay
336c85a053
rustdoc: Preserve rendering of macro_rules matchers when possible 2021-12-27 14:20:18 -08:00
bors
41c3017c82 Auto merge of #92099 - matthiaskrgr:rollup-4gwv67m, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #91141 (Revert "Temporarily rename int_roundings functions to avoid conflicts")
 - #91984 (Remove `in_band_lifetimes` from `rustc_middle`)
 - #92028 (Sync portable-simd to fix libcore build for AVX-512 enabled targets)
 - #92042 (Enable `#[thread_local]` for all windows-msvc targets)
 - #92071 (Update example code for Vec::splice to change the length)
 - #92077 (rustdoc: Remove unused `collapsed` field)
 - #92081 (rustdoc: Remove unnecessary `need_backline` function)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-19 12:36:56 +00:00
bors
a41a6925ba Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obk
Remove `SymbolStr`

This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences.

Best reviewed one commit at a time.

r? `@oli-obk`
2021-12-19 09:31:37 +00:00
Joshua Nelson
dea1c68614 Remove collapsed field
`render/context` always runs after `run_global_context`, so it was always set to `true`.

This is a holdover from when rustdoc allowed configuring passes, but the `collapse-docs` pass was
removed ages ago, and the ability to configure passes is about to be removed.
2021-12-18 10:47:54 -06:00
Nicholas Nethercote
b1c934ebb8 Remove unnecessary sigils around Ident::as_str() calls. 2021-12-15 17:32:42 +11:00
klensy
8869dbc2a0 don't alloc Path and mutate it inplace 2021-12-12 20:43:23 +03:00
Mark Rousskov
971c549ca3 re-format with new rustfmt 2021-11-30 13:08:41 -05:00
Noah Lev
79c718f1d5 Rename Type::ResolvedPath to Type::Path
At last! The new name is shorter, simpler, and consistent with
`hir::Ty`.
2021-11-26 12:40:27 -08:00
Noah Lev
d81deb33fa Stop re-exporting Type::ResolvedPath
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-25 12:08:05 -08:00
Noah Lev
617bbb21f8
Update comment
Co-authored-by: Joshua Nelson <github@jyn.dev>
2021-11-24 18:32:03 -05:00
Noah Lev
43651125ee Remove ResolvedPath.did 2021-11-24 12:06:47 -08:00
Noah Lev
47266bacf1 Return the actual DefId for assoc. items in register_res
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-24 12:00:53 -08:00
bors
49d42325d0 Auto merge of #90844 - camelid:cleanup-vis, r=jyn514
rustdoc: Finish transition to computed visibility

This finishes the transition to using computed visibility in rustdoc.
2021-11-21 13:26:31 +00:00
Noah Lev
bbc3825d26 rustdoc: Move doc-reachability visiting back to cleaning
It populates `cx.cache.access_levels`, which seems to be needed during
cleaning since a bunch of tests are failing.
2021-11-19 22:00:37 -05:00
Noah Lev
f41beab5cd rustdoc: Remove Crate.externs and compute on-demand instead 2021-11-19 21:28:52 -05:00
Noah Lev
7a7698aa1b rustdoc: Clean Visibility outside of display_macro_source
This change should make the code a bit clearer and easier to change.
2021-11-17 10:52:06 -05:00
Gary Guo
02c1774cd3 Give inline const separate DefKind 2021-11-07 03:59:06 +00:00
Noah Lev
a58e214894 rustdoc: Stop sorting external crates
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-30 11:16:26 -07:00
Noah Lev
ebe9a11f71 rustdoc: Remove Crate.name and instead compute it on-demand
It is not as large as `Crate.src` was, but it's still 8 bytes, and
`clean::Crate` is moved by-value a lot.
2021-10-30 11:16:24 -07:00
Noah Lev
85f8ae8ec4 rustdoc: Remove Crate.src and instead compute it on-demand
It is only used in one place; `src` was about a third of `Crate`'s total
size; `Crate` is frequently moved by-value; and `src` can be easily
computed on-demand.
2021-10-30 11:16:00 -07:00
Guillaume Gomez
4614ca4541 Fix clippy lints in librustdoc 2021-10-25 11:30:09 +02:00
bors
a8f2463c68 Auto merge of #88379 - camelid:cleanup-clean, r=jyn514
rustdoc: Cleanup various `clean` types

Cleanup various `clean` types.
2021-10-09 19:05:08 +00:00
Noah Lev
f9f3c9feb4 Rename strip_path to strip_path_generics
The new name is more descriptive of what the function does.
2021-10-03 11:20:35 -07:00
Noah Lev
91d3b7201e Use Path instead of Type in PolyTrait
The change to `impl Clean<Path> for hir::TraitRef<'_>` was necessary to
fix a test failure for `src/test/rustdoc/trait-alias-mention.rs`.
Here's why:

The old code path was through `impl Clean<Type> for hir::TraitRef<'_>`,
which called `resolve_type`, which in turn called `register_res`. Now,
because `PolyTrait` uses a `Path` instead of a `Type`, the impl of
`Clean<Path>` was being run, which did not call `register_res`, causing
the trait alias to not be recorded in the `external_paths` cache.
2021-09-30 13:52:58 -07:00
Noah Lev
d91946b3f4 Remove Path.global 2021-09-30 13:52:57 -07:00
Camille GILLOT
db9fea508a Avoid more invocations of hir_crate query. 2021-09-29 23:16:47 +02:00
Noah Lev
07d6454a0f Remove Type::ResolvedPath.is_generic
It can be computed on-demand.
2021-09-12 13:27:06 -07:00
Noah Lev
280fc2dcce rustdoc: Cleanup a pattern match in external_generic_args() 2021-09-11 16:01:49 -07:00
Noah Lev
913764dcef Remove unnecessary is_trait argument
It was only used for sugaring `Fn` trait bounds, and rustdoc already
checks that the `did` is for a `Fn` (or `FnMut`, `FnOnce`) lang item,
so it's not necessary to also check that the `did` belongs to a trait.
2021-09-11 15:55:21 -07:00
Noah Lev
5321b35a5a Fix redundant arguments in external_path()
If the path is for a trait, it is always true that `trait_did ==
Some(did)`, so instead, `external_path()` now takes an `is_trait`
boolean.
2021-09-11 15:43:44 -07:00
Noah Lev
c2207f5a48 Remove unused hir_id parameter from resolve_type 2021-09-11 11:24:54 -07:00
Noah Lev
6a84d34784 Create a valid Res in external_path()
The order of the `where` bounds on auto trait impls changed because
rustdoc currently sorts auto trait `where` bounds based on the `Debug`
output for the bound. Now that the bounds have an actual `Res`, they are
being unintentionally sorted by their `DefId` rather than their path.
So, I had to update a test for the change in ordering of the rendered
bounds.
2021-09-11 11:24:53 -07:00
Noah Lev
0bb1c285af rustdoc: Get symbol for TyParam directly 2021-09-11 11:24:53 -07:00
Noah Lev
44e6f2e90f Remove unnecessary Cache.*_did fields
They can be obtained by accessing the `TyCtxt` where they are needed.
2021-09-09 19:17:38 -07:00
Noah Lev
5c0e6c18e1 rustdoc: Box GenericArg::Const to reduce enum size 2021-09-03 14:34:58 -07:00
lcnr
bfaf13af4e make unevaluated const substs optional 2021-08-26 11:00:30 +02:00
Yuki Okushi
eef510865a
Rollup merge of #86889 - jyn514:crate-cleanup, r=camelid
rustdoc: Cleanup ExternalCrate

- Remove unnecessary CrateNum from Cache.externs
- Remove trival impl Clean for CrateNum
2021-07-18 14:21:55 +09:00
Cameron Steffen
1537cd4fb1 Remove refs from pat slices 2021-07-15 16:09:57 -05:00
Joshua Nelson
a30fa08928 Remove trival impl Clean for CrateNum 2021-07-13 20:21:58 -04:00
Joshua Nelson
e32eceefe1 Remove unnecessary CrateNum from Cache.externs
It can be found from ExternalCrate.
2021-07-13 20:21:54 -04:00
Guillaume Gomez
84f259e44c Unify macro source display 2021-07-07 11:30:08 +02:00
bors
09d9b608d6 Auto merge of #86282 - camelid:macro_rules-matchers, r=jyn514
Pretty-print macro matchers instead of using source code

Fixes #86208.
2021-07-05 05:09:35 +00:00