diff options
| author | Guillaume Gomez <guillaume.gomez@huawei.com> | 2024-06-19 15:54:08 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume.gomez@huawei.com> | 2024-08-13 20:14:55 +0200 |
| commit | 84d9b67dabd195c21fd210150facd2a8eccac908 (patch) | |
| tree | 08b5f2f226c57028f653d4292c27fd48e0e77ec1 | |
| parent | 14f80f9e69be3802792736eb11584d9f39229c48 (diff) | |
| download | rust-84d9b67dabd195c21fd210150facd2a8eccac908.tar.gz rust-84d9b67dabd195c21fd210150facd2a8eccac908.zip | |
Add 2024 edition doctests to cover corner cases
| -rw-r--r-- | tests/rustdoc-ui/2024-doctests-checks.rs | 41 | ||||
| -rw-r--r-- | tests/rustdoc-ui/2024-doctests-checks.stdout | 14 |
2 files changed, 55 insertions, 0 deletions
diff --git a/tests/rustdoc-ui/2024-doctests-checks.rs b/tests/rustdoc-ui/2024-doctests-checks.rs new file mode 100644 index 00000000000..6f62c0f73ad --- /dev/null +++ b/tests/rustdoc-ui/2024-doctests-checks.rs @@ -0,0 +1,41 @@ +//@ check-pass +//@ compile-flags: --test --test-args=--test-threads=1 -Zunstable-options --edition 2024 +//@ normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +//@ normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" +//@ normalize-stdout-test "wrong-ast.rs:\d+:\d+" -> "wrong-ast.rs:$$LINE:$$COL" + +/// This one should fail: crate attributes should remain crate attributes +/// in standalone doctests. +/// +/// ```compile_fail +/// #![deny(missing_docs)] +/// +/// pub struct Bar; +/// ``` +/// +/// This one should not impact the other merged doctests. +/// +/// ``` +/// #![deny(unused)] +/// ``` +/// +/// ``` +/// let x = 12; +/// ``` +/// +/// This one should not be a merged doctest (because of `$crate`): +/// +/// ``` +/// macro_rules! bla { +/// () => {{ +/// $crate::foo(); +/// }} +/// } +/// +/// fn foo() {} +/// +/// fn main() { +/// bla!(); +/// } +/// ``` +pub struct Foo; diff --git a/tests/rustdoc-ui/2024-doctests-checks.stdout b/tests/rustdoc-ui/2024-doctests-checks.stdout new file mode 100644 index 00000000000..2c0136f7674 --- /dev/null +++ b/tests/rustdoc-ui/2024-doctests-checks.stdout @@ -0,0 +1,14 @@ + +running 2 tests +test $DIR/2024-doctests-checks.rs - Foo (line 18) ... ok +test $DIR/2024-doctests-checks.rs - Foo (line 22) ... ok + +test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME + + +running 2 tests +test $DIR/2024-doctests-checks.rs - Foo (line 10) - compile fail ... ok +test $DIR/2024-doctests-checks.rs - Foo (line 28) ... ok + +test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME + |
