Add regression ui test for #140162 and for #139651

(cherry picked from commit 81438c0b05)
This commit is contained in:
Guillaume Gomez 2025-04-23 22:09:35 +02:00 committed by Josh Stone
parent 0457f2e927
commit 745d54e5b2
2 changed files with 28 additions and 0 deletions

View file

@ -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!");
//! }
//! ```

View file

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