diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-04-23 22:09:35 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-04-23 22:09:35 +0200 |
| commit | 81438c0b05f177ae7bc0d6511d1cc507652eb241 (patch) | |
| tree | c3ed8a4296d385dbc3b4b4b041c5313b4ce94acf | |
| parent | 35363245657ee53a3735f1cef0df9a45e9ed44b9 (diff) | |
| download | rust-81438c0b05f177ae7bc0d6511d1cc507652eb241.tar.gz rust-81438c0b05f177ae7bc0d6511d1cc507652eb241.zip | |
Add regression ui test for #140162 and for #139651
| -rw-r--r-- | tests/rustdoc-ui/doctest/test-main-alongside-exprs.rs | 22 | ||||
| -rw-r--r-- | tests/rustdoc-ui/doctest/test-main-alongside-exprs.stdout | 6 |
2 files changed, 28 insertions, 0 deletions
diff --git a/tests/rustdoc-ui/doctest/test-main-alongside-exprs.rs b/tests/rustdoc-ui/doctest/test-main-alongside-exprs.rs new file mode 100644 index 00000000000..ee2299c0fd8 --- /dev/null +++ b/tests/rustdoc-ui/doctest/test-main-alongside-exprs.rs @@ -0,0 +1,22 @@ +// This test ensures that if there is an expression alongside a `main` +// function, it will not consider the entire code to be part of the `main` +// function and will generate its own function to wrap everything. +// +// This is a regression test for: +// * <https://github.com/rust-lang/rust/issues/140162> +// * <https://github.com/rust-lang/rust/issues/139651> +//@ compile-flags:--test +//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" +//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" +//@ check-pass + +#![crate_name = "foo"] + +//! ``` +//! # if cfg!(miri) { return; } +//! use std::ops::Deref; +//! +//! fn main() { +//! println!("Hi!"); +//! } +//! ``` diff --git a/tests/rustdoc-ui/doctest/test-main-alongside-exprs.stdout b/tests/rustdoc-ui/doctest/test-main-alongside-exprs.stdout new file mode 100644 index 00000000000..90d7c3546bf --- /dev/null +++ b/tests/rustdoc-ui/doctest/test-main-alongside-exprs.stdout @@ -0,0 +1,6 @@ + +running 1 test +test $DIR/test-main-alongside-exprs.rs - (line 15) ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME + |
