diff options
| author | bors <bors@rust-lang.org> | 2022-06-16 11:13:30 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-06-16 11:13:30 +0000 |
| commit | 6ec3993ef4a4eb72bc20477fe9a4d92acd53f2c6 (patch) | |
| tree | 64623290e8e88fc28d678a5b928dc9595fcbcea0 /src/test/rustdoc | |
| parent | d40f24e956a698e47a209541031c4045acc5a684 (diff) | |
| parent | f1d24beb6805e4d16d472964518c576421f8c009 (diff) | |
| download | rust-6ec3993ef4a4eb72bc20477fe9a4d92acd53f2c6.tar.gz rust-6ec3993ef4a4eb72bc20477fe9a4d92acd53f2c6.zip | |
Auto merge of #97842 - notriddle:notriddle/tuple-docs, r=jsha,GuillaumeGomez
Improve the tuple and unit trait docs * Reduce duplicate impls; show only the `(T,)` and include a sentence saying that there exists ones up to twelve of them. * Show `Copy` and `Clone`. * Show auto traits like `Send` and `Sync`, and blanket impls like `Any`. Here's the new version: * <https://notriddle.com/notriddle-rustdoc-test/std/primitive.tuple.html> * <https://notriddle.com/notriddle-rustdoc-test/std/primitive.unit.html>
Diffstat (limited to 'src/test/rustdoc')
| -rw-r--r-- | src/test/rustdoc/primitive-tuple-auto-trait.rs | 22 | ||||
| -rw-r--r-- | src/test/rustdoc/primitive-tuple-variadic.rs | 18 | ||||
| -rw-r--r-- | src/test/rustdoc/primitive-unit-auto-trait.rs | 14 |
3 files changed, 54 insertions, 0 deletions
diff --git a/src/test/rustdoc/primitive-tuple-auto-trait.rs b/src/test/rustdoc/primitive-tuple-auto-trait.rs new file mode 100644 index 00000000000..71b0b077009 --- /dev/null +++ b/src/test/rustdoc/primitive-tuple-auto-trait.rs @@ -0,0 +1,22 @@ +// compile-flags: --crate-type lib --edition 2018 + +#![crate_name = "foo"] +#![feature(rustdoc_internals)] + +// @has foo/primitive.tuple.html '//a[@class="primitive"]' 'tuple' +// @has - '//span[@class="in-band"]' 'Primitive Type tuple' +// @has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' +// @has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations' +// @has - '//div[@id="synthetic-implementations-list"]//h3' 'Send' +// @has - '//div[@id="synthetic-implementations-list"]//h3' 'Sync' +#[doc(primitive = "tuple")] +/// this is a test! +/// +// Hardcoded anchor to header written in library/core/src/primitive_docs.rs +// @has - '//h2[@id="trait-implementations-1"]' 'Trait implementations' +/// # Trait implementations +/// +/// This header is hard-coded in the HTML format linking for `#[doc(tuple_variadics)]`. +/// To make sure it gets linked correctly, we need to make sure the hardcoded anchor +/// in the code matches what rustdoc generates for the header. +mod tuple_prim {} diff --git a/src/test/rustdoc/primitive-tuple-variadic.rs b/src/test/rustdoc/primitive-tuple-variadic.rs new file mode 100644 index 00000000000..4fd6254f674 --- /dev/null +++ b/src/test/rustdoc/primitive-tuple-variadic.rs @@ -0,0 +1,18 @@ +// compile-flags: --crate-type lib --edition 2018 + +#![crate_name = "foo"] +#![feature(rustdoc_internals)] + +pub trait Foo {} + +// @has foo/trait.Foo.html +// @has - '//section[@id="impl-Foo-for-(T%2C)"]/h3' 'impl<T> Foo for (T₁, T₂, …, Tₙ)' +#[doc(tuple_variadic)] +impl<T> Foo for (T,) {} + +pub trait Bar {} + +// @has foo/trait.Bar.html +// @has - '//section[@id="impl-Bar-for-(U%2C)"]/h3' 'impl<U: Foo> Bar for (U₁, U₂, …, Uₙ)' +#[doc(tuple_variadic)] +impl<U: Foo> Bar for (U,) {} diff --git a/src/test/rustdoc/primitive-unit-auto-trait.rs b/src/test/rustdoc/primitive-unit-auto-trait.rs new file mode 100644 index 00000000000..76182622ef5 --- /dev/null +++ b/src/test/rustdoc/primitive-unit-auto-trait.rs @@ -0,0 +1,14 @@ +// compile-flags: --crate-type lib --edition 2018 + +#![crate_name = "foo"] +#![feature(rustdoc_internals)] + +// @has foo/primitive.unit.html '//a[@class="primitive"]' 'unit' +// @has - '//span[@class="in-band"]' 'Primitive Type unit' +// @has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' +// @has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations' +// @has - '//div[@id="synthetic-implementations-list"]//h3' 'impl Send for ()' +// @has - '//div[@id="synthetic-implementations-list"]//h3' 'impl Sync for ()' +#[doc(primitive = "unit")] +/// this is a test! +mod unit_prim {} |
