Skip to content

Can we stop rustc --test warning of an unused main()? #12327

Closed
@chris-morgan

Description

@chris-morgan
$ echo 'fn main(){}' | rustc --test -
<anon>:1:1: 1:12 warning: code is never used: `main`, #[warn(dead_code)] on by default
<anon>:1 fn main(){}
         ^~~~~~~~~~~

I have put #[cfg(not(test))] on main a couple of times (though perhaps #[allow(dead_code)] would be better) and I have just observed another person doing it. Would it be reasonable to make the dead code lint permit main to be unused?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions