about summary refs log tree commit diff
path: root/tests/rustdoc-ui/doctest/warn-main-not-called.rs
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2025-04-30 20:38:12 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2025-05-02 13:57:53 +0200
commit5b86fa8282c6dc9d61c7f358f8cc2ea9c3a93330 (patch)
treedfe2a652d09bf3ae450718962c7165592e316fd9 /tests/rustdoc-ui/doctest/warn-main-not-called.rs
parentb791eaa4480a8e3acffe3faad4de0462b8476aca (diff)
downloadrust-5b86fa8282c6dc9d61c7f358f8cc2ea9c3a93330.tar.gz
rust-5b86fa8282c6dc9d61c7f358f8cc2ea9c3a93330.zip
Add regression test for #140310
Diffstat (limited to 'tests/rustdoc-ui/doctest/warn-main-not-called.rs')
-rw-r--r--tests/rustdoc-ui/doctest/warn-main-not-called.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/rustdoc-ui/doctest/warn-main-not-called.rs b/tests/rustdoc-ui/doctest/warn-main-not-called.rs
new file mode 100644
index 00000000000..25d92e9cee9
--- /dev/null
+++ b/tests/rustdoc-ui/doctest/warn-main-not-called.rs
@@ -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() {}
+//! ```