Skip to content

Commit aab2b67

Browse files
Add regression test for #131893
1 parent 0e0a84a commit aab2b67

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

Diff for: tests/rustdoc-ui/doctest/nested-main.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//@ check-pass
2+
//@ compile-flags:--test --test-args=--test-threads=1
3+
//@ normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR"
4+
//@ normalize-stdout-test: "finished in \d+\.\d+s" -> "finished in $$TIME"
5+
6+
// Regression test for <https://github.com/rust-lang/rust/issues/131893>.
7+
// It ensures that if a function called `main` is nested, it will not consider
8+
// it as the `main` function.
9+
10+
/// ```
11+
/// fn dox() {
12+
/// fn main() {}
13+
/// }
14+
/// ```
15+
pub fn foo() {}
16+
17+
// This one ensures that having a nested `main` doesn't prevent the
18+
// actual `main` function to be detected.
19+
/// ```
20+
/// fn main() {
21+
/// fn main() {}
22+
/// }
23+
/// ```
24+
pub fn foo2() {}

Diff for: tests/rustdoc-ui/doctest/nested-main.stdout

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
running 2 tests
3+
test $DIR/nested-main.rs - foo (line 10) ... ok
4+
test $DIR/nested-main.rs - foo2 (line 19) ... ok
5+
6+
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
7+

0 commit comments

Comments
 (0)