diff options
| author | Guillaume Gomez <guillaume.gomez@huawei.com> | 2023-04-25 15:04:46 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume.gomez@huawei.com> | 2023-09-15 21:32:28 +0200 |
| commit | f5561842e3dfc9adc8da4ba12b95514da4d99f00 (patch) | |
| tree | c4fdfbd2d3ceeec51431bef931829c380c97946c /tests/rustdoc-ui | |
| parent | 5515fc88dc45c274f0574d381a17d4f72dfd5047 (diff) | |
| download | rust-f5561842e3dfc9adc8da4ba12b95514da4d99f00.tar.gz rust-f5561842e3dfc9adc8da4ba12b95514da4d99f00.zip | |
Add tests for `custom_code_classes_in_docs` feature
Diffstat (limited to 'tests/rustdoc-ui')
7 files changed, 136 insertions, 0 deletions
diff --git a/tests/rustdoc-ui/custom_code_classes_in_docs-warning.rs b/tests/rustdoc-ui/custom_code_classes_in_docs-warning.rs new file mode 100644 index 00000000000..c28921b01f1 --- /dev/null +++ b/tests/rustdoc-ui/custom_code_classes_in_docs-warning.rs @@ -0,0 +1,19 @@ +// This test ensures that warnings are working as expected for "custom_code_classes_in_docs" +// feature. + +#![feature(custom_code_classes_in_docs)] +#![deny(warnings)] +#![feature(no_core)] +#![no_core] + +/// ```{. class= whatever=hehe #id} } {{ +/// main; +/// ``` +//~^^^ ERROR missing class name after `.` +//~| ERROR missing class name after `class=` +//~| ERROR unsupported attribute `whatever=hehe` +//~| ERROR unsupported attribute `#id` +//~| ERROR unexpected `}` outside attribute block (`{}`) +//~| ERROR unclosed attribute block (`{}`): missing `}` at the end +//~| ERROR unexpected `{` inside attribute block (`{}`) +pub fn foo() {} diff --git a/tests/rustdoc-ui/custom_code_classes_in_docs-warning.stderr b/tests/rustdoc-ui/custom_code_classes_in_docs-warning.stderr new file mode 100644 index 00000000000..f19b62914db --- /dev/null +++ b/tests/rustdoc-ui/custom_code_classes_in_docs-warning.stderr @@ -0,0 +1,65 @@ +error: missing class name after `.` + --> $DIR/custom_code_classes_in_docs-warning.rs:9:1 + | +LL | / /// ```{. class= whatever=hehe #id} } {{ +LL | | /// main; +LL | | /// ``` + | |_______^ + | +note: the lint level is defined here + --> $DIR/custom_code_classes_in_docs-warning.rs:5:9 + | +LL | #![deny(warnings)] + | ^^^^^^^^ + = note: `#[deny(rustdoc::invalid_codeblock_attributes)]` implied by `#[deny(warnings)]` + +error: missing class name after `class=` + --> $DIR/custom_code_classes_in_docs-warning.rs:9:1 + | +LL | / /// ```{. class= whatever=hehe #id} } {{ +LL | | /// main; +LL | | /// ``` + | |_______^ + +error: unsupported attribute `whatever=hehe` + --> $DIR/custom_code_classes_in_docs-warning.rs:9:1 + | +LL | / /// ```{. class= whatever=hehe #id} } {{ +LL | | /// main; +LL | | /// ``` + | |_______^ + +error: unsupported attribute `#id` + --> $DIR/custom_code_classes_in_docs-warning.rs:9:1 + | +LL | / /// ```{. class= whatever=hehe #id} } {{ +LL | | /// main; +LL | | /// ``` + | |_______^ + +error: unexpected `}` outside attribute block (`{}`) + --> $DIR/custom_code_classes_in_docs-warning.rs:9:1 + | +LL | / /// ```{. class= whatever=hehe #id} } {{ +LL | | /// main; +LL | | /// ``` + | |_______^ + +error: unexpected `{` inside attribute block (`{}`) + --> $DIR/custom_code_classes_in_docs-warning.rs:9:1 + | +LL | / /// ```{. class= whatever=hehe #id} } {{ +LL | | /// main; +LL | | /// ``` + | |_______^ + +error: unclosed attribute block (`{}`): missing `}` at the end + --> $DIR/custom_code_classes_in_docs-warning.rs:9:1 + | +LL | / /// ```{. class= whatever=hehe #id} } {{ +LL | | /// main; +LL | | /// ``` + | |_______^ + +error: aborting due to 7 previous errors + diff --git a/tests/rustdoc-ui/custom_code_classes_in_docs-warning2.rs b/tests/rustdoc-ui/custom_code_classes_in_docs-warning2.rs new file mode 100644 index 00000000000..b2ce7407ec6 --- /dev/null +++ b/tests/rustdoc-ui/custom_code_classes_in_docs-warning2.rs @@ -0,0 +1,13 @@ +// This test ensures that warnings are working as expected for "custom_code_classes_in_docs" +// feature. + +#![feature(custom_code_classes_in_docs)] +#![deny(warnings)] +#![feature(no_core)] +#![no_core] + +/// ```{class=} +/// main; +/// ``` +//~^^^ ERROR missing class name after `class=` +pub fn foo() {} diff --git a/tests/rustdoc-ui/custom_code_classes_in_docs-warning2.stderr b/tests/rustdoc-ui/custom_code_classes_in_docs-warning2.stderr new file mode 100644 index 00000000000..52bb1dae9f6 --- /dev/null +++ b/tests/rustdoc-ui/custom_code_classes_in_docs-warning2.stderr @@ -0,0 +1,17 @@ +error: missing class name after `class=` + --> $DIR/custom_code_classes_in_docs-warning2.rs:9:1 + | +LL | / /// ```{class=} +LL | | /// main; +LL | | /// ``` + | |_______^ + | +note: the lint level is defined here + --> $DIR/custom_code_classes_in_docs-warning2.rs:5:9 + | +LL | #![deny(warnings)] + | ^^^^^^^^ + = note: `#[deny(rustdoc::invalid_codeblock_attributes)]` implied by `#[deny(warnings)]` + +error: aborting due to previous error + diff --git a/tests/rustdoc-ui/feature-gate-custom_code_classes_in_docs.rs b/tests/rustdoc-ui/feature-gate-custom_code_classes_in_docs.rs new file mode 100644 index 00000000000..8aa13b2d5d1 --- /dev/null +++ b/tests/rustdoc-ui/feature-gate-custom_code_classes_in_docs.rs @@ -0,0 +1,5 @@ +/// ```{class=language-c} +/// int main(void) { return 0; } +/// ``` +//~^^^ ERROR 1:1: 3:8: custom classes in code blocks are unstable [E0658] +pub struct Bar; diff --git a/tests/rustdoc-ui/feature-gate-custom_code_classes_in_docs.stderr b/tests/rustdoc-ui/feature-gate-custom_code_classes_in_docs.stderr new file mode 100644 index 00000000000..c41ebfc8073 --- /dev/null +++ b/tests/rustdoc-ui/feature-gate-custom_code_classes_in_docs.stderr @@ -0,0 +1,15 @@ +error[E0658]: custom classes in code blocks are unstable + --> $DIR/feature-gate-custom_code_classes_in_docs.rs:1:1 + | +LL | / /// ```{class=language-c} +LL | | /// int main(void) { return 0; } +LL | | /// ``` + | |_______^ + | + = note: see issue #79483 <https://github.com/rust-lang/rust/issues/79483> for more information + = help: add `#![feature(custom_code_classes_in_docs)]` to the crate attributes to enable + = note: found these custom classes: class=language-c + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/rustdoc-ui/issues/issue-91713.stdout b/tests/rustdoc-ui/issues/issue-91713.stdout index 16783524363..bbea7e5c212 100644 --- a/tests/rustdoc-ui/issues/issue-91713.stdout +++ b/tests/rustdoc-ui/issues/issue-91713.stdout @@ -1,4 +1,5 @@ Available passes for running rustdoc: +check-custom-code-classes - check for custom code classes without the feature-gate enabled check_doc_test_visibility - run various visibility-related lints on doctests strip-hidden - strips all `#[doc(hidden)]` items from the output strip-private - strips all private items from a crate which cannot be seen externally, implies strip-priv-imports @@ -10,6 +11,7 @@ calculate-doc-coverage - counts the number of items with and without documentati run-lints - runs some of rustdoc's lints Default passes for rustdoc: +check-custom-code-classes collect-trait-impls check_doc_test_visibility strip-hidden (when not --document-hidden-items) |
