-
Notifications
You must be signed in to change notification settings - Fork 13.3k
"the main function must be defined at the crate level" for doc test regression 1.81->1.82 #131893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@joshka can you provide the exact file configuration (files and directories) that reproduces the issue? I'm sorry, I'm probably missing the obvious. thanks |
Pasting it into the playground and choosing "test" hits the error, so a new project with the above in |
ok, if my bisection is correct, it points to e5b3e68 (though I'm not completely sure how it's relevant) |
The function for checking for functions named rust/src/librustdoc/doctest/make.rs Lines 288 to 291 in e5b3e68
It likely instead needs to stop the recursion level at the automatically generated doctest function. That new function wrapper was created so that the tests can be merged into a single file and compiled once for speed rather than a file per doctest. In addition to the change here, the line numbers in errors in the new approach make it difficult to correlate multiple failures into a source document. This seems to have always been the case, but to have gotten worse with the doc test merging in 1.82. I haven't checked whether there's another bug raised for this, but it will be related the the same code change here. |
1.82 introduced a regression in book tests: rust-lang/rust#131893
1.82 introduced a regression in book tests: rust-lang/rust#131893
Sending a fix. |
…r=notriddle [rustdoc] Do not consider nested functions as main function even if named `main` in doctests Fixes rust-lang#131893. If a nested function is called `main`, it is not considered as the entry point of the program. Therefore, doctests should not consider such functions as such either. r? `@notriddle`
…r=notriddle [rustdoc] Do not consider nested functions as main function even if named `main` in doctests Fixes rust-lang#131893. If a nested function is called `main`, it is not considered as the entry point of the program. Therefore, doctests should not consider such functions as such either. r? `@notriddle`
The tokio.rs website tests all the code blocks in markdown files by building up a rust file with code included as doc comments on generated functions. The code is generally wrapped in a function to avoid any main functions being interpreted as a test main function. In 1.81, this worked fine, but 1.82 sees the internal main function and treats it as one which prevents the default test main being created.
Code
I tried this code:
I expected to see this happen:
cargo test
should succeedInstead, this happened: cargo test failed
Version it worked on
It most recently worked on: 1.81
rustc --version --verbose
:@rustbot modify labels: +regression-from-stable-to-stable -regression-untriaged
The text was updated successfully, but these errors were encountered: