Skip to content

Rustdoc should emit a warning if a main function is surrounded by non-items in a doctest #140310

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

Open
GuillaumeGomez opened this issue Apr 25, 2025 · 0 comments
Assignees
Labels
A-doctests Area: Documentation tests, run by rustdoc A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-feature-request Category: A feature request, i.e: not implemented / a PR. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@GuillaumeGomez
Copy link
Member

GuillaumeGomez commented Apr 25, 2025

For example:

//! ```
//! let x = 12;
//!
//! fn main() {
//!     // this code is never run
//! }
//! ```

In this case, the main function will be wrapped into another main function and won't be run. We should warn about it.

@GuillaumeGomez GuillaumeGomez added A-doctests Area: Documentation tests, run by rustdoc T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Apr 25, 2025
@GuillaumeGomez GuillaumeGomez self-assigned this Apr 25, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 25, 2025
@GuillaumeGomez GuillaumeGomez removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 25, 2025
@fmease fmease added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Apr 25, 2025
@fmease fmease changed the title Rustdoc should emit a warning if a main function is surrounded by non-function items Rustdoc should emit a warning if a main function is surrounded by non-items in a doctest Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-doctests Area: Documentation tests, run by rustdoc A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-feature-request Category: A feature request, i.e: not implemented / a PR. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
Status: No status
Development

No branches or pull requests

3 participants