bors
5ffebc2cb3
Auto merge of #96301 - notriddle:notriddle/synthetic-impl-prim, r=GuillaumeGomez
...
rustdoc: make primitive synthetic impls for correct doc module
This improves the accuracy of libcore primitive docs, which was missing the blanket and auto impls for most primitive types. To test this, compare nightly [libcore::str] docs, which lack auto traits like Send, with [std::str] docs, which show them.
[libcore::str]: https://doc.rust-lang.org/nightly/core/primitive.str.html
[libstd::str]: https://doc.rust-lang.org/nightly/std/primitive.str.html
It also avoids getting synthetic impls for primitive types on crates that do not actually show them.
<details>
<summary>Before and After trace logs</summary>
## Before
[notriddle@deep-thought test-dingus]$ RUSTDOC_LOG=rustdoc=trace rustdoc +nightly test.rs 2>&1 | grep -E 'get_blanket_impls\('
TRACE rustdoc::clean::blanket_impl get_blanket_impls(Whatever)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(isize)
TRACE rustdoc::clean::blanket_impl get_blanket_impls([T])
TRACE rustdoc::clean::blanket_impl get_blanket_impls([u8])
TRACE rustdoc::clean::blanket_impl get_blanket_impls([T])
TRACE rustdoc::clean::blanket_impl get_blanket_impls([u8])
TRACE rustdoc::clean::blanket_impl get_blanket_impls(char)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(u128)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(u16)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(i128)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(i16)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(str)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(str)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(f64)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(f64)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(u64)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(u8)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(i64)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(i8)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(*const T)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(*mut T)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(*const [T])
TRACE rustdoc::clean::blanket_impl get_blanket_impls(*mut [T])
TRACE rustdoc::clean::blanket_impl get_blanket_impls([T; N])
TRACE rustdoc::clean::blanket_impl get_blanket_impls(bool)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(f32)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(f32)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(u32)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(usize)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(i32)
## After
[notriddle@deep-thought test-dingus]$ RUSTDOC_LOG=rustdoc=trace rustdoc +dev test.rs 2>&1 | grep -E 'get_blanket_impls\('
TRACE rustdoc::clean::blanket_impl get_blanket_impls(Whatever)
</details>
2022-04-22 16:47:13 +00:00
bors
8b2393086f
Auto merge of #96282 - petrochenkov:unindent, r=GuillaumeGomez
...
rustdoc: Unindent doc fragments on `Attributes` construction
`Attributes` can be constructed at arbitrary points, even after the `unindent_comments` pass.
`Attributes` that are constructed too late end up unindented.
All doc fragments need to be eventually indented before use, so there are no reasons to not do this immediately during their construction.
Fixes https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/.60unindent_comments.60.20cannot.20work.20as.20a.20separate.20pass .
I'm not sure how to make a minimized reproduction, but unindenting the fragments during their construction should fix the issue.. by construction, and I also verified that all doc strings now hit the `resolver_caches.markdown_links` cache in https://github.com/rust-lang/rust/pull/94857 .
2022-04-22 02:30:27 +00:00
Michael Howell
2e7b5abbfd
rustdoc: make primitive synthetic impls for correct doc module
...
This improves the accuracy of libcore primitive docs, which was missing the
blanket and auto impls for most primitive types. To test this, compare nightly
[libcore::str] docs, which lack auto traits like Send, with [std::str] docs,
which show them.
[libcore::str]: https://doc.rust-lang.org/nightly/core/primitive.str.html
[libstd::str]: https://doc.rust-lang.org/nightly/std/primitive.str.html
It also avoids getting synthetic impls for primitive types on crates that
do not actually show them.
<details>
<summary>Before and After trace logs</summary>
Before:
[notriddle@deep-thought test-dingus]$ RUSTDOC_LOG=rustdoc=trace rustdoc +nightly test.rs 2>&1 | grep -E 'get_blanket_impls\('
TRACE rustdoc::clean::blanket_impl get_blanket_impls(Whatever)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(isize)
TRACE rustdoc::clean::blanket_impl get_blanket_impls([T])
TRACE rustdoc::clean::blanket_impl get_blanket_impls([u8])
TRACE rustdoc::clean::blanket_impl get_blanket_impls([T])
TRACE rustdoc::clean::blanket_impl get_blanket_impls([u8])
TRACE rustdoc::clean::blanket_impl get_blanket_impls(char)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(u128)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(u16)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(i128)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(i16)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(str)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(str)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(f64)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(f64)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(u64)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(u8)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(i64)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(i8)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(*const T)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(*mut T)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(*const [T])
TRACE rustdoc::clean::blanket_impl get_blanket_impls(*mut [T])
TRACE rustdoc::clean::blanket_impl get_blanket_impls([T; N])
TRACE rustdoc::clean::blanket_impl get_blanket_impls(bool)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(f32)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(f32)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(u32)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(usize)
TRACE rustdoc::clean::blanket_impl get_blanket_impls(i32)
After:
[notriddle@deep-thought test-dingus]$ RUSTDOC_LOG=rustdoc=trace rustdoc +dev test.rs 2>&1 | grep -E 'get_blanket_impls\('
TRACE rustdoc::clean::blanket_impl get_blanket_impls(Whatever)
</details>
2022-04-21 17:06:33 -07:00
bors
0b3404b01b
Auto merge of #96261 - petrochenkov:doclink7, r=GuillaumeGomez
...
rustdoc: Resolve some more doc links early
Trying another subset of https://github.com/rust-lang/rust/pull/94857 that is not too expensive.
2022-04-22 00:05:17 +00:00
bors
de1bc0008b
Auto merge of #96260 - Kobzol:rustdoc-idmap, r=petrochenkov
...
rustdoc: Optimize IdMap
Slightly optimizes `IdMap`, which is hot in `markdown_links` (context [here](https://github.com/rust-lang/rust/pull/96135#issuecomment-1103539052 )). There are more improvements that can be made near this place, but this seemed like an easy win locally (although I tried it on top of https://github.com/rust-lang/rust/pull/94857 , so let's see what happens without that PR).
r? `@petrochenkov`
2022-04-21 18:31:57 +00:00
Vadim Petrochenkov
7803a41151
rustdoc: Unindent doc fragments on Attributes construction
2022-04-21 16:13:02 +03:00
bors
3d3dafb771
Auto merge of #95828 - vacuus:rustdoc-print-where-clause, r=notriddle
...
rustdoc: Clean up `html::format::print_where_clause`
(Arguably) closes https://github.com/rust-lang/rust/issues/95814
2022-04-21 08:12:38 +00:00
bors
7be1da0319
Auto merge of #96263 - Dylan-DPC:rollup-0eofl13, r=Dylan-DPC
...
Rollup of 5 pull requests
Successful merges:
- #90630 (Create real parser for search queries)
- #96193 ([fuchsia] Add implementation for `current_exe`)
- #96196 (Remove assertion that all paths in `ShouldRun` exist)
- #96228 (Fix locations for intrinsics impls and change to links)
- #96236 (Add an explicit `Span` field to `OutlivesConstraint`)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-21 02:16:32 +00:00
Roc Yu
5d59c16c2d
rustdoc: Clean up html::format::print_where_clause
2022-04-20 20:45:30 -04:00
Dylan DPC
976c6b2d19
Rollup merge of #90630 - GuillaumeGomez:improve-rustdoc-search, r=notriddle
...
Create real parser for search queries
You can test it [here](https://rustdoc.crud.net/imperio/improve-rustdoc-search/std/index.html ).
This PR adds a real parser for the query engine in rustdoc. The parser is quite simple but it allows to makes query handling much easier. I added a new testsuite to ensure it works as expected and ran fuzzing checks on it for a few hours without problems.
So about the parser: as you can see in the screenshot, it handles recursive generics parsing. It also allows to set which item should use exact matching by adding double-quotes around it (look for `exact_search` in the screenshot).
Now about the query engine itself: I simplified it a lot thanks to the parsed query. It behaves mostly the same when there is only one argument, but is much more powerful when there are more than one.
When making this change, we also removed the support for multi-query.
PS: A big part of the PR is tests and test-related code. :)
r? `@camelid`
2022-04-21 01:14:13 +02:00
Vadim Petrochenkov
e0b71fff2a
[WIP] rustdoc: Resolve some more doc links early
2022-04-21 01:18:02 +03:00
Jakub Beránek
34e2d3bab8
rustdoc: Optimize IdMap
2022-04-21 00:15:04 +02:00
Guillaume Gomez
4d26bde4f0
Extend handleSingleArg documentation
2022-04-20 21:11:39 +02:00
Guillaume Gomez
f988f86cdc
Remove <> links to be potential intra-doc links
2022-04-20 20:28:15 +02:00
bors
d39864d64e
Auto merge of #96135 - petrochenkov:doclink6, r=GuillaumeGomez
...
rustdoc: Optimize and refactor doc link resolution
One more subset of https://github.com/rust-lang/rust/pull/94857 that should bring perf improvements rather than regressions + a couple more optimizations on top of it.
It's better to read individual commits and their descriptions to understand the changes.
The `may_have_doc_links` optimization is not *very* useful here, but it's much more important for https://github.com/rust-lang/rust/pull/94857 .
Closes https://github.com/rust-lang/rust/issues/96079
2022-04-20 13:34:48 +00:00
Dylan DPC
a0ba15bfab
Rollup merge of #95813 - Urgau:rustdoc-where-clause-space, r=GuillaumeGomez
...
Remove extra space before a where clause
Remove extra space before where clause in the generated documentation.
The fix is to move the space before the break-line so that it doesn't appear visually but is still here. Removing it completely would create things like this `impl<D> Delta<D>where D: MyTrait` (missing a space before the where) which I don't think we want.
Added two regression test, first one test that the `<br>` is after the space and the second check that the `<br>` is before the spaces.
Before:

After:

r? ``@GuillaumeGomez``
2022-04-19 22:57:40 +02:00
Vadim Petrochenkov
5cce8cb4ec
rustdoc: Sligthly optimize Attributes construction and processing before doc link resolution
2022-04-19 22:53:50 +03:00
Vadim Petrochenkov
de287df862
rustdoc: Cache preprocessed markdown links
2022-04-19 22:53:50 +03:00
Vadim Petrochenkov
72ed101428
rustdoc: Optimize and refactor doc link resolution
...
- Cache doc link resolutions obtained early
- Cache markdown links retrieved from doc strings early
- Rename and restructure the code in early doc link resolution to be closer to #94857
2022-04-19 22:53:50 +03:00
Dylan DPC
9fad214593
Rollup merge of #96142 - cjgillot:no-crate-def-index, r=petrochenkov
...
Stop using CRATE_DEF_INDEX outside of metadata encoding.
`CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want. We should not manipulate raw `DefIndex` outside of metadata encoding.
2022-04-19 14:43:21 +02:00
Guillaume Gomez
8d0e10cfbe
Correctly handle single :
2022-04-18 23:11:42 +02:00
Guillaume Gomez
299e8ee25e
Add an extra check over filter type
2022-04-18 21:43:19 +02:00
Guillaume Gomez
d7d538a8c4
Fix some corner cases
2022-04-18 20:59:09 +02:00
Guillaume Gomez
6f35475ba5
Parse idents the same way in both quote string elements and "normal" elements
2022-04-18 20:59:09 +02:00
Guillaume Gomez
a6051c76db
Remove unnecessary elem.name.length === 0 since the rustdoc search eBNF does not allow elements without a name
2022-04-18 20:59:09 +02:00
Guillaume Gomez
51b4005003
Update the eBNF to allow generics bracket to not be closed if it's EOF
2022-04-18 20:59:09 +02:00
Guillaume Gomez
e03a950747
Handle separators in their own functions and fix missing handling of tabs
2022-04-18 20:59:09 +02:00
Guillaume Gomez
da829d8d9d
Improve the BNF description a bit and fix some issues
2022-04-18 20:59:09 +02:00
Guillaume Gomez
1f5c4c2b30
Forbid rustdoc search query to end with ->
2022-04-18 20:59:09 +02:00
Guillaume Gomez
8e29ed43d9
Add isIdentCharacter function to ensure that unexpected characters are handled correctly
2022-04-18 20:59:09 +02:00
Guillaume Gomez
f9251eef68
Replace unneeded use of regex with a simple if
2022-04-18 20:59:09 +02:00
Guillaume Gomez
699ae365df
Apply suggestions:
...
* Forbid generics without a path (so "<p>" is forbidden).
* Change `handleSingleArg` so that it takes `results_others`, `results_in_args` and `results_returned` as arguments instead of using the "global" variables.
* Change `createQueryElement` so that it returns the newly created element instead of taking `elems` as argument.
* Improve documentation
2022-04-18 20:59:09 +02:00
Guillaume Gomez
c7de1a16f8
Improve documentation and add some explanations in the code
2022-04-18 20:59:09 +02:00
Guillaume Gomez
49297337b4
Simplify parser syntax
2022-04-18 20:59:08 +02:00
Guillaume Gomez
99d552092c
Make query parser more strict and improve display of errors
2022-04-18 20:59:08 +02:00
Guillaume Gomez
264064df36
* Greatly improve the rustdoc search parser source code
...
* Move all functions outside parseQuery
2022-04-18 20:59:08 +02:00
Guillaume Gomez
99c5394ecc
Add query syntax for the parser
2022-04-18 20:59:08 +02:00
Guillaume Gomez
51de26cfd9
* If type filter is in quotes, throw an error.
...
* If there are generics, don't allow to have quotes.
2022-04-18 20:59:08 +02:00
Guillaume Gomez
bbcf1762dd
Improve naming of "val" field
2022-04-18 20:59:08 +02:00
Guillaume Gomez
3aeef67037
Update search engine and parser to error when quotes are used on queries with more than one element.
2022-04-18 20:59:08 +02:00
Guillaume Gomez
be41750a10
Greatly improve rustdoc search
2022-04-18 20:59:08 +02:00
Guillaume Gomez
caa770aee1
Fix rustdoc duplicated blanket impls issue
2022-04-17 18:04:10 +02:00
Camille GILLOT
07ee031763
Stop using CRATE_DEF_INDEX.
...
`CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want.
2022-04-17 12:14:42 +02:00
Loïc BRANSTETT
f7ce145d83
Remove extra space before a where clause in the documentation
2022-04-17 12:00:52 +02:00
Dylan DPC
10e0db5666
Rollup merge of #96118 - GuillaumeGomez:cleanup-def-id-item-id, r=notriddle
...
rustdoc: Rename `def_id` into `item_id` when the type is `ItemId` for readability
As `@notriddle` mentioned in https://github.com/rust-lang/rust/pull/96091 , the field name is inaccurate. This PR fixes it by renaming it accordingly to its real type.
r? `@notriddle`
2022-04-16 19:42:07 +02:00
Guillaume Gomez
b1e6211c5c
Rename def_id into item_id when the type is ItemId for readability
2022-04-16 14:28:09 +02:00
Dylan DPC
1bce78aa97
Rollup merge of #96059 - euclio:doc-cfg, r=manishearth,guillaumegomez
...
clarify doc(cfg) wording
The current "This is supported" wording implies that it's possible to
still use the item on other configurations, but in an unsupported way.
Changing this to "Available" removes this ambiguity.
2022-04-16 14:26:00 +02:00
Dylan DPC
91847c43cc
Rollup merge of #96023 - matthiaskrgr:clippyper1304, r=lcnr
...
couple of clippy::perf fixes
2022-04-16 14:25:56 +02:00
Dylan DPC
bdbf0998f3
Rollup merge of #95194 - kckeiks:update-algo-in-find-use-placement, r=pnkfelix
...
remove find_use_placement
A more robust solution to finding where to place use suggestions was added in #94584 .
The algorithm uses the AST to find the span for the suggestion so we pass this span
down to the HIR during lowering and use it instead of calling `find_use_placement`
Fixes #94941
2022-04-15 20:50:45 +02:00
Andy Russell
753d567989
clarify doc(cfg) wording
...
The current "This is supported" wording implies that it's possible to
still use the item on other configurations, but in an unsupported way.
Changing this to "Available" removes this ambiguity.
2022-04-14 21:12:13 -04:00