mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Add regression test for #140310
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
//@ check-pass
|
||||
//@ compile-flags:--test --test-args --test-threads=1
|
||||
//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR"
|
||||
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
|
||||
|
||||
// In case there is a `main` function in the doctest alongside expressions,
|
||||
// the whole doctest will be wrapped into a function and the `main` function
|
||||
// won't be called.
|
||||
|
||||
//! ```
|
||||
//! macro_rules! bla {
|
||||
//! ($($x:tt)*) => {}
|
||||
//! }
|
||||
//!
|
||||
//! let x = 12;
|
||||
//! bla!(fn main ());
|
||||
//! ```
|
||||
//!
|
||||
//! ```
|
||||
//! let x = 12;
|
||||
//! fn main() {}
|
||||
//! ```
|
||||
@@ -0,0 +1,14 @@
|
||||
warning: the `main` function of this doctest won't be run as it contains expressions at the top level, meaning that the whole doctest code will be wrapped in a function
|
||||
--> $DIR/warn-main-not-called.rs:10:1
|
||||
|
|
||||
10 | //! ```
|
||||
| ^^^^^^^
|
||||
|
||||
warning: the `main` function of this doctest won't be run as it contains expressions at the top level, meaning that the whole doctest code will be wrapped in a function
|
||||
--> $DIR/warn-main-not-called.rs:19:1
|
||||
|
|
||||
19 | //! ```
|
||||
| ^^^^^^^
|
||||
|
||||
warning: 2 warnings emitted
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
running 2 tests
|
||||
test $DIR/warn-main-not-called.rs - (line 10) ... ok
|
||||
test $DIR/warn-main-not-called.rs - (line 19) ... ok
|
||||
|
||||
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
|
||||
|
||||
Reference in New Issue
Block a user