Skip to content
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

rustc -Wall to show all possible warnings #10234

Closed
mcandre opened this issue Nov 2, 2013 · 6 comments · Fixed by #48765
Closed

rustc -Wall to show all possible warnings #10234

mcandre opened this issue Nov 2, 2013 · 6 comments · Fixed by #48765
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@mcandre
Copy link

mcandre commented Nov 2, 2013

It would be nice if rustc -Wall turned on all warnings, like how other compilers work.

@thestinger
Copy link
Contributor

At least with clang and gcc, -Wall doesn't turn on all the warnings. I don't think turning all on the warnings is ever going to be useful because lots are going to be very domain specific (ones like heap-memory already are).

clang has a fairly useless -Weverything to turn on all warnings, and -Wmost to turn on all those included by -Wall, -Wextra and also many more that are considered to be useful. Rust already has all the warnings viewed as useful and not too subjective on by default.

@mcandre
Copy link
Author

mcandre commented Nov 2, 2013

@thestinger Oh, wow! Thanks for the detailed, thoughtful response. I'll definitely look into each of those options.

@thestinger
Copy link
Contributor

(FWIW the warnings are listed in -W help and are almost all on by default)

@sanmai-NL
Copy link

sanmai-NL commented May 23, 2017

I think there should be a catch-all lint group, that objectively enables all lints. Whenever programmers decide subjectively to allow lints in some instances, they may then do that on a case-by-case basis. And if an implemented lint simply does not make sense at all then it should be improved/removed. The existing lint group warnings apparently does not include all built-in lint groups, contrary to the output of rustc -W help (rustc 1.19.0-nightly (01951a61a 2017-05-20)):

Lint groups provided by rustc:

                   name  sub-lints
                   ----  ---------
               warnings  all built-in lints
              bad-style  non-camel-case-types, non-snake-case, non-upper-case-globals
    future-incompatible  private-in-public, inaccessible-extern-crate, invalid-type-param-default, super-or-self-in-global-path, illegal-floating-point-constant-pattern, illegal-floating-point-literal-pattern, illegal-struct-or-enum-constant-pattern, hr-lifetime-in-assoc-type, lifetime-underscore, resolve-trait-on-defaulted-unit, safe-extern-statics, patterns-in-fns-without-body, extra-requirement-in-impl, legacy-directory-ownership, legacy-imports, legacy-constructor-visibility, missing-fragment-specifier, anonymous-parameters
                 unused  unused-imports, unused-variables, unused-assignments, dead-code, unused-mut, unreachable-code, unreachable-patterns, unused-must-use, unused-unsafe, path-statements, unused-attributes, unused-macros

@Mark-Simulacrum can this issue be reopened?

@Mark-Simulacrum
Copy link
Member

Reopening.

However, I think we shouldn't have any sort of "enable all lints" option; rustc's lints are already all intended to have no or very few false positives (and as such are enabled by default where that makes sense). Could you talk about which specific lints are missing from the default warnings built-in list? I'm not personally aware of any. I'm also somewhat concerned that a -Wall or similar option would be confusing to some extent because "all" wouldn't include clippy lints (and probably can't, or at least not easily -- though I don't know the details here).

@steveklabnik steveklabnik added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 23, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-feature-request Category: A feature request, i.e: not implemented / a PR. label Jul 19, 2017
@Phlosioneer
Copy link
Contributor

Issue triage:

rustc -W help no longer prints warnings all built-in lints, so that was fixed at some point. (it now prints warnings all lints that are set to issue warnings)

I think it might be useful to have a message explaining why -Wall doesn't exist, point the user toward -W help to see all available errors, and suggest adding a #![warn(unused)] for a more thorough lint check. This would help beginners coming from other languages to 1) understand that most useful warnings are turned on by default, 2) tell the user that -W help exists, and 3) show the user that warnings can be controlled from inside the source code, rather than the command line.

If there's interest in doing this, I could make a PR.

kennytm added a commit to kennytm/rust that referenced this issue Mar 14, 2018
…, r=estebank

Add info message for -Wall command

Users coming from other languages (namely C and C++) often expect
to use a -Wall flag. Rustc doesn't support that, and previously it
simply printed that it didn't recognize the "all" lint.

This change makes rustc print out a help message, explaining:
- Why there is no -Wall flag
- How to view all the available warnings
- Point out that the most commonly used warning is -Wunused
- Instead of using a command-line flag, the user should consider
  a !#[warn(unused)] directive in the root of their crate.

I tried to keep the language consistent with the other usage help. Comment if I should change anything.

closes rust-lang#10234, if accepted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants