diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2024-10-24 15:05:39 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2024-10-24 21:35:15 +0200 |
| commit | aab2b6747db09b8572f879bd74dbee701287536d (patch) | |
| tree | abe6e27852f766a5c630734ec7229997cf0411ff | |
| parent | 0e0a84ae4e656fda2becd9ba33428fff613b44cb (diff) | |
| download | rust-aab2b6747db09b8572f879bd74dbee701287536d.tar.gz rust-aab2b6747db09b8572f879bd74dbee701287536d.zip | |
Add regression test for #131893
| -rw-r--r-- | tests/rustdoc-ui/doctest/nested-main.rs | 24 | ||||
| -rw-r--r-- | tests/rustdoc-ui/doctest/nested-main.stdout | 7 |
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/rustdoc-ui/doctest/nested-main.rs b/tests/rustdoc-ui/doctest/nested-main.rs new file mode 100644 index 00000000000..e939ba81214 --- /dev/null +++ b/tests/rustdoc-ui/doctest/nested-main.rs @@ -0,0 +1,24 @@ +//@ check-pass +//@ compile-flags:--test --test-args=--test-threads=1 +//@ normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" +//@ normalize-stdout-test: "finished in \d+\.\d+s" -> "finished in $$TIME" + +// Regression test for <https://github.com/rust-lang/rust/issues/131893>. +// It ensures that if a function called `main` is nested, it will not consider +// it as the `main` function. + +/// ``` +/// fn dox() { +/// fn main() {} +/// } +/// ``` +pub fn foo() {} + +// This one ensures that having a nested `main` doesn't prevent the +// actual `main` function to be detected. +/// ``` +/// fn main() { +/// fn main() {} +/// } +/// ``` +pub fn foo2() {} diff --git a/tests/rustdoc-ui/doctest/nested-main.stdout b/tests/rustdoc-ui/doctest/nested-main.stdout new file mode 100644 index 00000000000..af9a8f5e1d7 --- /dev/null +++ b/tests/rustdoc-ui/doctest/nested-main.stdout @@ -0,0 +1,7 @@ + +running 2 tests +test $DIR/nested-main.rs - foo (line 10) ... ok +test $DIR/nested-main.rs - foo2 (line 19) ... ok + +test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME + |
