Add 2024 edition doctests to cover corner cases

This commit is contained in:
Guillaume Gomez 2024-06-19 15:54:08 +02:00
parent 14f80f9e69
commit 84d9b67dab
2 changed files with 55 additions and 0 deletions

View File

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

View File

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