Add tests for custom_code_classes_in_docs
feature
This commit is contained in:
parent
5515fc88dc
commit
f5561842e3
9 changed files with 268 additions and 27 deletions
19
tests/rustdoc-ui/custom_code_classes_in_docs-warning.rs
Normal file
19
tests/rustdoc-ui/custom_code_classes_in_docs-warning.rs
Normal file
|
@ -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() {}
|
65
tests/rustdoc-ui/custom_code_classes_in_docs-warning.stderr
Normal file
65
tests/rustdoc-ui/custom_code_classes_in_docs-warning.stderr
Normal file
|
@ -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
|
||||
|
13
tests/rustdoc-ui/custom_code_classes_in_docs-warning2.rs
Normal file
13
tests/rustdoc-ui/custom_code_classes_in_docs-warning2.rs
Normal file
|
@ -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() {}
|
17
tests/rustdoc-ui/custom_code_classes_in_docs-warning2.stderr
Normal file
17
tests/rustdoc-ui/custom_code_classes_in_docs-warning2.stderr
Normal file
|
@ -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
|
||||
|
|
@ -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;
|
|
@ -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`.
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue