Skip to content

Disable needless_main_doctest by defaultΒ #4858

Closed
@gnzlbg

Description

@gnzlbg

This lint is recommending me to remove the fn main() in jemalloc-ctl doctests, e.g., see these ones at the top-level: https://docs.rs/jemalloc-ctl/0.3.3/jemalloc_ctl/#examples

I personally think that the fn main() significantly increases the clarity of these particular doctests.

Also, one does not have to write fn main(), one explicitly must opt into writing it. Warning by default when one has explicitly opted into doing so feels like a bad idea.

So IMO this lint should not even be enabled when clippy::pedantic is enabled.

Looking at the lint PR, I can't find an issue or a discussion about the "need" for this lint. Which crate authors were writing fn main() in doctests out of ignorance that it could be left out, to the point that doing so warrants a lint ? The book and rust-by-example all omit fn main, so I'm skeptical that anybody learning Rust from any official resource would have picked up the habit of writing fn main() in doctest "by accident". In my experience, one has to go deep into the rustdoc documentation to figure out that this is even possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions