about summary refs log tree commit diff
path: root/src/test/rustdoc
AgeCommit message (Collapse)AuthorLines
2021-06-22Rollup merge of #86334 - LeSeulArtichaut:86120-links-type-aliases, r=jyn514Yuki Okushi-0/+19
Resolve type aliases to the type they point to in intra-doc links This feels a bit sketchy, but I think it's better than just rejecting the link. Helps with #86120, r? ``@jyn514``
2021-06-22Do not list impl when trait has doc(hidden)Deadbeef-0/+25
2021-06-21Readd `unsafe` keyword in testsDeadbeef-6/+6
2021-06-21Removed/Updated some cases and simplified `match`Deadbeef-28/+3
2021-06-21Added some tests for `unsafe` in const-dispay.rsDeadbeef-6/+47
2021-06-21Check for const_unstable before printing `const`Deadbeef-4/+4
2021-06-21Resolve type aliases to the type they point to in intra-doc linksLeSeulArtichaut-0/+19
2021-06-20"(const: unstable)" for stable-but-const-unstableDeadbeef-0/+2
2021-06-19rustdoc: Introduce new `DynTrait` type for better representation of trait ↵Justus K-0/+8
objects
2021-06-18rustdoc: Render `<Self as X>::Y` type casts properly across crate boundsJustus K-1/+30
2021-06-18rustdoc: Render `for<'_>` lifetimes in trait objectsJustus K-17/+17
2021-06-18rustdoc: Render `for<'_>` lifetimes in front of where boundJustus K-0/+41
2021-06-18Auto merge of #86322 - trinity-1686a:rustdoc-fix-overflow-recursive-deref, ↵bors-0/+44
r=jyn514 fix rustdoc stack overflow on mutually recursive Deref fix #85095 fix #85037
2021-06-16Fix target highlighting in rustdoc.Jacob Hoffman-Andrews-9/+1
Also factor out outer_version and const_outer_version into render_rightside.
2021-06-16Make portability part of the summary.Jacob Hoffman-Andrews-3/+3
That means it will be visible under "Implementors" on trait pages, and under "Implementations" on struct/enum pages, even when all methods are collapsed. Switch to a float layout for rightside elements.
2021-06-16Remove methods under Implementors on trait pagesJacob Hoffman-Andrews-20/+0
These were hidden by default, and duplicated information already on the page anyhow. Also remove the "Auto-hide trait implementors of a trait" setting, which is not needed anymore.
2021-06-16rename test-casesTrinity Pointard-4/+4
2021-06-16Rollup merge of #86327 - GuillaumeGomez:safe-intrinsics, r=lqdYuki Okushi-0/+20
Don't mark "safe" intrinsics as unsafe A good example of this is [intrinsics::abort](https://doc.rust-lang.org/nightly/core/intrinsics/fn.abort.html). Before: ![Screenshot from 2021-06-15 14-58-42](https://user-images.githubusercontent.com/3050060/122056942-65ddad00-cdea-11eb-829e-5f5e258387de.png) After: ![Screenshot from 2021-06-15 14-59-22](https://user-images.githubusercontent.com/3050060/122056956-6aa26100-cdea-11eb-94d8-e18b4956cfa4.png) cc ``@jyn514`` r? ``@lqd``
2021-06-16Rollup merge of #86242 - BoxyUwU:rustdoc-const-evaluatable-ice, r=oli-obkYuki Okushi-0/+7
rustdoc- dont ICE on `ConstEvaluatable` predicates Fixes #77647 rustdoc doesn't need to be handling these as you cant write them, they just get added implicitly when you write a where clause containing an expression.
2021-06-15Add test for safe intrinsicsGuillaume Gomez-0/+20
2021-06-15remove code for recursive Deref in sidebarTrinity Pointard-0/+22
fix #85037
2021-06-15fix rustdoc stack overflow on mutually recursive DerefTrinity Pointard-0/+22
fix #85095
2021-06-15Rollup merge of #86277 - jsha:remove-must-use, r=ManishearthYuki Okushi-42/+1
Remove must_use from ALLOWED_ATTRIBUTES This is a fairly common attribute on methods, but is not something you need to know when reading the method docs - the purpose of the attribute is for the compiler to tell you about it if you forget to use a value. Removing reclaims some valuable space in the summary of methods, particularly when the attribute has a long string value. As discussed in #84309. Partially addresses #81482. r? ```@Manishearth```
2021-06-15Auto merge of #84867 - pnkfelix:rustdoc-revert-deref-recur, r=jyn514bors-66/+18
rustdoc: revert deref recur to resume inclusion of impl ExtTrait<Local> for ExtType As discussed here: https://github.com/rust-lang/rust/issues/82465#issuecomment-829290384, Revert PR #80653 to resolve issue #82465. Issue #82465 was we had stopped including certain trait implementations, namely implementations on an imported type of an imported trait *instantiated on a local type*. That bug was injected by PR #80653. Reverting #80653 means we don't list all the methods that you have accessible via recursively applying `Deref`. [Discussion in last week's rustc triage meeting](https://zulip-archive.rust-lang.org/238009tcompilermeetings/19557weekly2021042954818.html#236680594) led us to conclude that the bug was worse than the enhancement, and there was not an obvious fix for the bug itself. So for the short term we remove the enhancement, while in the long term we will work on figuring out a way to have our imported trait implementation cake and eat it too.
2021-06-13Remove must_use from ALLOWED_ATTRIBUTESJacob Hoffman-Andrews-42/+1
This is a fairly common attribute on methods, but is not something you need to know when reading the method docs - the purpose of the attribute is for the compiler to tell you about it if you forget to use a value. Removing reclaims some valuable space in the summary of methods.
2021-06-12add `@has`Ellen-0/+2
2021-06-12lineEllen-1/+1
2021-06-12dont ICE on `ConstEvaluatable` predicatesEllen-0/+5
2021-06-10Auto merge of #86098 - pietroalbini:test-stable, r=Mark-Simulacrumbors-2/+2
Add the x86_64-gnu-stable builder During the 1.52 release process we had to deal with some commits that passed the test suite on the nightly branch but failed on the beta or stable branch. In that case it was due to some UI tests including the channel name in the output, but other changes might also be dependent on the channel. This commit adds a new CI job that runs the Linux x86_64 test suite with the stable branch, ensuring nightly changes also work as stable. To ensure the new job works the following other changes are present: * The `ui-fulldeps/session-derive-errors.rs` test has been disabled on beta and stable, which required adding support for `// ignore-{channel}` and `// only-{channel}`. * The `rustdoc/intra-doc/field.rs` has been fixed. r? `@Mark-Simulacrum` fixes https://github.com/rust-lang/release-team/issues/11
2021-06-10regression test for issue 82465.Felix S. Klock II-0/+16
2021-06-10manually crafted revert of PR #80653, to address issue #82465.Felix S. Klock II-66/+2
(update: placated tidy) (update: rebased post PR #84707 ) merge me
2021-06-09Rollup merge of #85957 - BoxyUwU:rustdoc-const-generic-defaults, r=oli-obkYuki Okushi-0/+6
Display defaults on const params- rustdoc previously rustdoc would render this struct declaration: `pub struct Foo<const N: usize = 10>;` as: `pub struct Foo<const N: usize>;` this PR changes it to render correctly
2021-06-07use channel-relative urls in rustdoc/intra-doc/field.rsPietro Albini-2/+2
2021-06-05Auto merge of #85457 - jyn514:remove-doc-include, r=GuillaumeGomezbors-19/+6
Remove `doc(include)` This nightly feature is redundant now that `extended_key_value_attributes` is stable (https://github.com/rust-lang/rust/pull/83366). `@rust-lang/rustdoc` not sure if you think this needs FCP; there was already an FCP in #82539, but technically it was for deprecating, not removing the feature altogether. This should not be merged before #83366. cc `@petrochenkov`
2021-06-05Rollup merge of #84942 - jyn514:channel-replace, r=ManishearthYuki Okushi-75/+74
rustdoc: link to stable/beta docs consistently in documentation This is an alternative to https://github.com/rust-lang/rust/pull/84941 which fixes the problem consistently by linking to stable/beta for *all* items, not just for primitives. ## User-facing changes - Intra-doc links to primitives that currently go to rust-lang.org/nightly/std/primitive.x.html will start going to channel that rustdoc was built with. Nightly will continue going to /nightly; Beta will link to /beta; stable compilers will link to /1.52.1 (or whatever version they were built as). - Cross-crate links from std to core currently go to /nightly unconditionally. They will start going to /1.52.0 on stable channels (but remain the same on nightly channels). - Intra-crate links from std to std (or core to core) currently go to the same URL they are hosted at; they will continue to do so. Notably, this is different from everything else because it can preserve the distinction between /stable and /1.52.0 by using relative links. Note that "links" includes both intra-doc links and rustdoc's own automatically generated hyperlinks. ## Implementation changes - Update the testsuite to allow linking to /beta and /1.52.1 in docs - Use an html_root_url for the standard library that's dependent on the channel This avoids linking to nightly docs on stable. - Update rustdoc to use channel-dependent links for primitives from an unknown crate - Set DOC_RUST_LANG_ORG_CHANNEL from bootstrap to ensure it's in sync - Include doc.rust-lang.org in the channel cc Mark-Simulacrum - I know [you were dubious about this in the past](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs/near/231223124), but I'm not quite sure why? I see this as "just a bugfix", I don't know why rustdoc should unconditionally link to nightly. cc dtolnay who commented in https://github.com/rust-lang/rust/issues/30693: > I would welcome a PR to solve this permanently if anyone has ideas for how. I don't believe we need an RFC. Fixes https://github.com/rust-lang/rust/issues/30693 (note that issue is marked as feature-accepted, although I don't see where it was discussed).
2021-06-05Rollup merge of #84880 - jyn514:cleanup-itemkind, r=GuillaumeGomezYuki Okushi-0/+4
Make match in `register_res` easier to read - Don't duplicate DefKind -> ItemType handling; that's a good way to get bugs - Use exhaustive match - Add comments This found that register_res is very wrong in at least one way: if it registers a Res for `Variant`, it should also register one for `Field`. But I don't know whether the one for Variant should be removed or Field added. Maybe someone has ideas? Found while reviewing https://github.com/rust-lang/rust/pull/84176.
2021-06-04rustdoc: link to stable/beta docs consistently in documentationJoshua Nelson-75/+74
## User-facing changes - Intra-doc links to primitives that currently go to rust-lang.org/nightly/std/primitive.x.html will start going to channel that rustdoc was built with. Nightly will continue going to /nightly; Beta will link to /beta; stable compilers will link to /1.52.1 (or whatever version they were built as). - Cross-crate links from std to core currently go to /nightly unconditionally. They will start going to /1.52.0 on stable channels (but remain the same on nightly channels). - Intra-crate links from std to std (or core to core) currently go to the same URL they are hosted at; they will continue to do so. Notably, this is different from everything else because it can preserve the distinction between /stable and /1.52.0 by using relative links. Note that "links" includes both intra-doc links and rustdoc's own automatically generated hyperlinks. ## Implementation changes - Update the testsuite to allow linking to /beta and /1.52.1 in docs - Use an html_root_url for the standard library that's dependent on the channel This avoids linking to nightly docs on stable. - Update rustdoc to use channel-dependent links for primitives from an unknown crate - Set DOC_RUST_LANG_ORG_CHANNEL from bootstrap to ensure it's in sync - Include doc.rust-lang.org in the channel
2021-06-04Remove `doc(include)`Joshua Nelson-19/+6
2021-06-03add testEllen-0/+6
2021-06-03Auto merge of #84834 - GuillaumeGomez:sidebar-unification, r=jshabors-1/+2
Sidebar unification This PR does a few things: * Put crates list at all levels (before, it was only on the "top" items) * Fix bug in module sidebar: the list of items was from the parent module. The other changes (on bootstrap mostly) were to allow to generate multiple crates in a same folder so that we can ensure that clicking on the crates in the sidebar works as expected. I added a rustdoc-gui test to ensure everything is where it should be. r? `@jyn514`
2021-06-02Update rustdoc testsGuillaume Gomez-94/+100
2021-06-01Replace h3 and h4 containing invalid DOMGuillaume Gomez-81/+82
2021-05-31Update rustdoc testGuillaume Gomez-1/+2
2021-05-30Remove toggle for "undocumented items."Jacob Hoffman-Andrews-44/+60
Per discussion in #84326. For trait implementations, this was misleading: the items actually do have documentation (but it comes from the trait definition). For both trait implementations and trait implementors, this was redundant: in both of those cases, the items are default-hidden by different toggle at the level above. Update tests: Remove XPath selectors that over-specified on details tag, in cases that weren't testing toggles. Add an explicit test for toggles on methods. Rename item-hide-threshold to toggle-item-contents for consistency.
2021-05-26Update trait toggle testGuillaume Gomez-1/+5
2021-05-23Auto merge of #85479 - Stupremee:render-Self_as-type-casts, r=CraftSpiderbors-0/+17
rustdoc: render `<Self as X>::Y` type casts properly Rustdoc didn't render any `<Self as X>` casts which causes invalid code inside the documentation. This is fixed by this PR by checking if the target type `X` is different from `Self`, and if so, it will render a typecast. Resolves #85454
2021-05-22Fix auto-hide for implementations and implementors.Jacob Hoffman-Andrews-1/+2
This sets their toggles to be closed in the HTML (matching the default setting), and opens them if the setting indicates to do so. This distinguishes between implementations and implementors based on being descendants of certain named elements.
2021-05-19rustdoc: add test for issue-85454Justus K-0/+17
2021-05-18Rollup merge of #83366 - jyn514:stabilize-key-value-attrs, r=petrochenkovJack Huey-1/+0
Stabilize extended_key_value_attributes Closes https://github.com/rust-lang/rust/issues/44732. Closes https://github.com/rust-lang/rust/issues/78835. Closes https://github.com/rust-lang/rust/issues/82768 (by making it irrelevant). # Stabilization report ## Summary This stabilizes using macro expansion in key-value attributes, like so: ```rust #[doc = include_str!("my_doc.md")] struct S; #[path = concat!(env!("OUT_DIR"), "/generated.rs")] mod m; ``` See Petrochenkov's excellent blog post [on internals](https://internals.rust-lang.org/t/macro-expansion-points-in-attributes/11455) for alternatives that were considered and rejected ("why accept no more and no less?") This has been available on nightly since 1.50 with no major issues. ## Notes ### Accepted syntax The parser accepts arbitrary Rust expressions in this position, but any expression other than a macro invocation will ultimately lead to an error because it is not expected by the built-in expression forms (e.g., `#[doc]`). Note that decorators and the like may be able to observe other expression forms. ### Expansion ordering Expansion of macro expressions in "inert" attributes occurs after decorators have executed, analogously to macro expressions appearing in the function body or other parts of decorator input. There is currently no way for decorators to accept macros in key-value position if macro expansion must be performed before the decorator executes (if the macro can simply be copied into the output for later expansion, that can work). ## Test cases - https://github.com/rust-lang/rust/blob/master/src/test/ui/attributes/key-value-expansion-on-mac.rs - https://github.com/rust-lang/rust/blob/master/src/test/rustdoc/external-doc.rs The feature has also been dogfooded extensively in the compiler and standard library: - https://github.com/rust-lang/rust/pull/83329 - https://github.com/rust-lang/rust/pull/83230 - https://github.com/rust-lang/rust/pull/82641 - https://github.com/rust-lang/rust/pull/80534 ## Implementation history - Initial proposal: https://github.com/rust-lang/rust/issues/55414#issuecomment-554005412 - Experiment to see how much code it would break: https://github.com/rust-lang/rust/pull/67121 - Preliminary work to restrict expansion that would conflict with this feature: https://github.com/rust-lang/rust/pull/77271 - Initial implementation: https://github.com/rust-lang/rust/pull/78837 - Fix for an ICE: https://github.com/rust-lang/rust/pull/80563 ## Unresolved Questions ~~https://github.com/rust-lang/rust/pull/83366#issuecomment-805180738 listed some concerns, but they have been resolved as of this final report.~~ ## Additional Information There are two workarounds that have a similar effect for `#[doc]` attributes on nightly. One is to emulate this behavior by using a limited version of this feature that was stabilized for historical reasons: ```rust macro_rules! forward_inner_docs { ($e:expr => $i:item) => { #[doc = $e] $i }; } forward_inner_docs!(include_str!("lib.rs") => struct S {}); ``` This also works for other attributes (like `#[path = concat!(...)]`). The other is to use `doc(include)`: ```rust #![feature(external_doc)] #[doc(include = "lib.rs")] struct S {} ``` The first works, but is non-trivial for people to discover, and difficult to read and maintain. The second is a strange special-case for a particular use of the macro. This generalizes it to work for any use case, not just including files. I plan to remove `doc(include)` when this is stabilized (https://github.com/rust-lang/rust/pull/82539). The `forward_inner_docs` workaround will still compile without warnings, but I expect it to be used less once it's no longer necessary.
2021-05-18Stabilize extended_key_value_attributesJoshua Nelson-1/+0
# Stabilization report ## Summary This stabilizes using macro expansion in key-value attributes, like so: ```rust #[doc = include_str!("my_doc.md")] struct S; #[path = concat!(env!("OUT_DIR"), "/generated.rs")] mod m; ``` See the changes to the reference for details on what macros are allowed; see Petrochenkov's excellent blog post [on internals](https://internals.rust-lang.org/t/macro-expansion-points-in-attributes/11455) for alternatives that were considered and rejected ("why accept no more and no less?") This has been available on nightly since 1.50 with no major issues. ## Notes ### Accepted syntax The parser accepts arbitrary Rust expressions in this position, but any expression other than a macro invocation will ultimately lead to an error because it is not expected by the built-in expression forms (e.g., `#[doc]`). Note that decorators and the like may be able to observe other expression forms. ### Expansion ordering Expansion of macro expressions in "inert" attributes occurs after decorators have executed, analogously to macro expressions appearing in the function body or other parts of decorator input. There is currently no way for decorators to accept macros in key-value position if macro expansion must be performed before the decorator executes (if the macro can simply be copied into the output for later expansion, that can work). ## Test cases - https://github.com/rust-lang/rust/blob/master/src/test/ui/attributes/key-value-expansion-on-mac.rs - https://github.com/rust-lang/rust/blob/master/src/test/rustdoc/external-doc.rs The feature has also been dogfooded extensively in the compiler and standard library: - https://github.com/rust-lang/rust/pull/83329 - https://github.com/rust-lang/rust/pull/83230 - https://github.com/rust-lang/rust/pull/82641 - https://github.com/rust-lang/rust/pull/80534 ## Implementation history - Initial proposal: https://github.com/rust-lang/rust/issues/55414#issuecomment-554005412 - Experiment to see how much code it would break: https://github.com/rust-lang/rust/pull/67121 - Preliminary work to restrict expansion that would conflict with this feature: https://github.com/rust-lang/rust/pull/77271 - Initial implementation: https://github.com/rust-lang/rust/pull/78837 - Fix for an ICE: https://github.com/rust-lang/rust/pull/80563 ## Unresolved Questions ~~https://github.com/rust-lang/rust/pull/83366#issuecomment-805180738 listed some concerns, but they have been resolved as of this final report.~~ ## Additional Information There are two workarounds that have a similar effect for `#[doc]` attributes on nightly. One is to emulate this behavior by using a limited version of this feature that was stabilized for historical reasons: ```rust macro_rules! forward_inner_docs { ($e:expr => $i:item) => { #[doc = $e] $i }; } forward_inner_docs!(include_str!("lib.rs") => struct S {}); ``` This also works for other attributes (like `#[path = concat!(...)]`). The other is to use `doc(include)`: ```rust #![feature(external_doc)] #[doc(include = "lib.rs")] struct S {} ``` The first works, but is non-trivial for people to discover, and difficult to read and maintain. The second is a strange special-case for a particular use of the macro. This generalizes it to work for any use case, not just including files. I plan to remove `doc(include)` when this is stabilized. The `forward_inner_docs` workaround will still compile without warnings, but I expect it to be used less once it's no longer necessary.