diff options
| author | bors <bors@rust-lang.org> | 2022-09-27 01:58:36 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-09-27 01:58:36 +0000 |
| commit | cd4d9d934fd3bc1b6a0b0fcb3548a1b26fc53c9d (patch) | |
| tree | 28b9a7976fd3103a1a2b087a1fac01e3519db8d4 /src/test | |
| parent | f3a6fbf2f2e898ca4d788b3e686726fa9770c676 (diff) | |
| parent | 7381d7d8b2594ec7dff32562ad7be705c6c0ebde (diff) | |
| download | rust-cd4d9d934fd3bc1b6a0b0fcb3548a1b26fc53c9d.tar.gz rust-cd4d9d934fd3bc1b6a0b0fcb3548a1b26fc53c9d.zip | |
Auto merge of #102331 - notriddle:rollup-dmefd2d, r=notriddle
Rollup of 6 pull requests Successful merges: - #102283 (Improve code example for Option::unwrap_or_default) - #102319 (rustdoc: merge CSS `table` rules into `.docblock`) - #102321 ( Rustdoc-Json: List impls for primitives) - #102322 (Document that Display automatically implements ToString) - #102325 (rustdoc: give `.line-number` / `.line-numbers` meaningful names) - #102326 (rustdoc: Update doc comment for splitn_mut to include mutable in the …) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/run-make-fulldeps/rustdoc-scrape-examples-macros/src/lib.rs | 8 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/basic-code.goml | 2 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/docblock-code-block-line-number.goml | 12 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/source-code-page.goml | 16 | ||||
| -rw-r--r-- | src/test/rustdoc-json/primitives/primitive_impls.rs | 34 | ||||
| -rw-r--r-- | src/test/rustdoc-json/primitives/primitive_overloading.rs (renamed from src/test/rustdoc-json/primitive_overloading.rs) | 0 | ||||
| -rw-r--r-- | src/test/rustdoc-json/primitives/primitive_type.rs (renamed from src/test/rustdoc-json/primitives.rs) | 0 | ||||
| -rw-r--r-- | src/test/rustdoc-json/primitives/use_primitive.rs (renamed from src/test/rustdoc-json/primitive.rs) | 2 |
8 files changed, 54 insertions, 20 deletions
diff --git a/src/test/run-make-fulldeps/rustdoc-scrape-examples-macros/src/lib.rs b/src/test/run-make-fulldeps/rustdoc-scrape-examples-macros/src/lib.rs index bac3970a4d3..d8658a0f255 100644 --- a/src/test/run-make-fulldeps/rustdoc-scrape-examples-macros/src/lib.rs +++ b/src/test/run-make-fulldeps/rustdoc-scrape-examples-macros/src/lib.rs @@ -1,8 +1,8 @@ // Scraped example should only include line numbers for items b and c in ex.rs -// @!has foobar/fn.f.html '//*[@class="line-numbers"]' '14' -// @has foobar/fn.f.html '//*[@class="line-numbers"]' '15' -// @has foobar/fn.f.html '//*[@class="line-numbers"]' '21' -// @!has foobar/fn.f.html '//*[@class="line-numbers"]' '22' +// @!has foobar/fn.f.html '//*[@class="src-line-numbers"]' '14' +// @has foobar/fn.f.html '//*[@class="src-line-numbers"]' '15' +// @has foobar/fn.f.html '//*[@class="src-line-numbers"]' '21' +// @!has foobar/fn.f.html '//*[@class="src-line-numbers"]' '22' pub fn f() {} diff --git a/src/test/rustdoc-gui/basic-code.goml b/src/test/rustdoc-gui/basic-code.goml index 27deb2c989c..79090b499c8 100644 --- a/src/test/rustdoc-gui/basic-code.goml +++ b/src/test/rustdoc-gui/basic-code.goml @@ -1,3 +1,3 @@ goto: file://|DOC_PATH|/test_docs/index.html click: ".srclink" -assert-count: (".line-numbers", 1) +assert-count: (".src-line-numbers", 1) diff --git a/src/test/rustdoc-gui/docblock-code-block-line-number.goml b/src/test/rustdoc-gui/docblock-code-block-line-number.goml index ebfffbce715..4e1e83c0fbd 100644 --- a/src/test/rustdoc-gui/docblock-code-block-line-number.goml +++ b/src/test/rustdoc-gui/docblock-code-block-line-number.goml @@ -2,7 +2,7 @@ goto: file://|DOC_PATH|/test_docs/fn.foo.html // We check that without this setting, there is no line number displayed. -assert-false: "pre.line-number" +assert-false: "pre.example-line-numbers" // We now set the setting to show the line numbers on code examples. local-storage: {"rustdoc-line-numbers": "true" } @@ -10,16 +10,16 @@ local-storage: {"rustdoc-line-numbers": "true" } reload: // We wait for them to be added into the DOM by the JS... -wait-for: "pre.line-number" +wait-for: "pre.example-line-numbers" // If the test didn't fail, it means that it was found! // Let's now check some CSS properties... -assert-css: ("pre.line-number", { +assert-css: ("pre.example-line-numbers", { "margin": "0px", "padding": "13px 8px", "text-align": "right", }) // The first code block has two lines so let's check its `<pre>` elements lists both of them. -assert-text: ("pre.line-number", "1\n2") +assert-text: ("pre.example-line-numbers", "1\n2") // Now, try changing the setting dynamically. We'll turn it off, using the settings menu, // and make sure it goes away. @@ -32,8 +32,8 @@ assert-css: ("#settings", {"display": "block"}) // Then, click the toggle button. click: "input#line-numbers + .slider" wait-for: 100 // wait-for-false does not exist -assert-false: "pre.line-number" +assert-false: "pre.example-line-numbers" // Finally, turn it on again. click: "input#line-numbers + .slider" -wait-for: "pre.line-number" +wait-for: "pre.example-line-numbers" diff --git a/src/test/rustdoc-gui/source-code-page.goml b/src/test/rustdoc-gui/source-code-page.goml index 581f826a3d9..5f0bb7f19c0 100644 --- a/src/test/rustdoc-gui/source-code-page.goml +++ b/src/test/rustdoc-gui/source-code-page.goml @@ -1,22 +1,22 @@ // Checks that the interactions with the source code pages are working as expected. goto: file://|DOC_PATH|/src/test_docs/lib.rs.html // Check that we can click on the line number. -click: ".line-numbers > span:nth-child(4)" // This is the span for line 4. +click: ".src-line-numbers > span:nth-child(4)" // This is the span for line 4. // Ensure that the page URL was updated. assert-document-property: ({"URL": "lib.rs.html#4"}, ENDS_WITH) assert-attribute: ("//*[@id='4']", {"class": "line-highlighted"}) // We now check that the good spans are highlighted goto: file://|DOC_PATH|/src/test_docs/lib.rs.html#4-6 -assert-attribute-false: (".line-numbers > span:nth-child(3)", {"class": "line-highlighted"}) -assert-attribute: (".line-numbers > span:nth-child(4)", {"class": "line-highlighted"}) -assert-attribute: (".line-numbers > span:nth-child(5)", {"class": "line-highlighted"}) -assert-attribute: (".line-numbers > span:nth-child(6)", {"class": "line-highlighted"}) -assert-attribute-false: (".line-numbers > span:nth-child(7)", {"class": "line-highlighted"}) +assert-attribute-false: (".src-line-numbers > span:nth-child(3)", {"class": "line-highlighted"}) +assert-attribute: (".src-line-numbers > span:nth-child(4)", {"class": "line-highlighted"}) +assert-attribute: (".src-line-numbers > span:nth-child(5)", {"class": "line-highlighted"}) +assert-attribute: (".src-line-numbers > span:nth-child(6)", {"class": "line-highlighted"}) +assert-attribute-false: (".src-line-numbers > span:nth-child(7)", {"class": "line-highlighted"}) // This is to ensure that the content is correctly align with the line numbers. compare-elements-position: ("//*[@id='1']", ".rust > code > span", ("y")) // Assert that the line numbers text is aligned to the right. -assert-css: (".line-numbers", {"text-align": "right"}) +assert-css: (".src-line-numbers", {"text-align": "right"}) // Now let's check that clicking on something else than the line number doesn't // do anything (and certainly not add a `#NaN` to the URL!). @@ -24,7 +24,7 @@ show-text: true goto: file://|DOC_PATH|/src/test_docs/lib.rs.html // We use this assert-position to know where we will click. assert-position: ("//*[@id='1']", {"x": 104, "y": 103}) -// We click on the left of the "1" span but still in the "line-number" `<pre>`. +// We click on the left of the "1" span but still in the "src-line-number" `<pre>`. click: (103, 103) assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH) diff --git a/src/test/rustdoc-json/primitives/primitive_impls.rs b/src/test/rustdoc-json/primitives/primitive_impls.rs new file mode 100644 index 00000000000..1fc9374065f --- /dev/null +++ b/src/test/rustdoc-json/primitives/primitive_impls.rs @@ -0,0 +1,34 @@ +#![feature(no_core)] +#![feature(rustc_attrs)] +#![feature(rustdoc_internals)] +#![no_core] +#![rustc_coherence_is_core] + +// @set impl_i32 = "$.index[*][?(@.docs=='Only core can do this')].id" + +/// Only core can do this +impl i32 { + // @set identity = "$.index[*][?(@.docs=='Do Nothing')].id" + + /// Do Nothing + pub fn identity(self) -> Self { + self + } + + // @is "$.index[*][?(@.docs=='Only core can do this')].inner.items[*]" $identity +} + +// @set Trait = "$.index[*][?(@.name=='Trait')].id" +pub trait Trait {} +// @set impl_trait_for_i32 = "$.index[*][?(@.docs=='impl Trait for i32')].id" +/// impl Trait for i32 +impl Trait for i32 {} + +/// i32 +#[doc(primitive = "i32")] +mod prim_i32 {} + +// @set i32 = "$.index[*][?(@.docs=='i32')].id" +// @is "$.index[*][?(@.docs=='i32')].name" '"i32"' +// @is "$.index[*][?(@.docs=='i32')].inner.name" '"i32"' +// @ismany "$.index[*][?(@.docs=='i32')].inner.impls[*]" $impl_i32 $impl_trait_for_i32 diff --git a/src/test/rustdoc-json/primitive_overloading.rs b/src/test/rustdoc-json/primitives/primitive_overloading.rs index 56b35cd14c0..56b35cd14c0 100644 --- a/src/test/rustdoc-json/primitive_overloading.rs +++ b/src/test/rustdoc-json/primitives/primitive_overloading.rs diff --git a/src/test/rustdoc-json/primitives.rs b/src/test/rustdoc-json/primitives/primitive_type.rs index 8024044bc05..8024044bc05 100644 --- a/src/test/rustdoc-json/primitives.rs +++ b/src/test/rustdoc-json/primitives/primitive_type.rs diff --git a/src/test/rustdoc-json/primitive.rs b/src/test/rustdoc-json/primitives/use_primitive.rs index 6454dd7f51f..e2292737462 100644 --- a/src/test/rustdoc-json/primitive.rs +++ b/src/test/rustdoc-json/primitives/use_primitive.rs @@ -5,7 +5,7 @@ #[doc(primitive = "usize")] mod usize {} -// @set local_crate_id = "$.index[*][?(@.name=='primitive')].crate_id" +// @set local_crate_id = "$.index[*][?(@.name=='use_primitive')].crate_id" // @has "$.index[*][?(@.name=='ilog10')]" // @!is "$.index[*][?(@.name=='ilog10')].crate_id" $local_crate_id |
