1
Fork 0

Add tests for custom_code_classes_in_docs feature

This commit is contained in:
Guillaume Gomez 2023-04-25 15:04:46 +02:00
parent 5515fc88dc
commit f5561842e3
9 changed files with 268 additions and 27 deletions

View 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() {}

View 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

View 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() {}

View 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

View file

@ -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;

View file

@ -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`.

View file

@ -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)