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

Add info message for -Wall command #48765

Merged
merged 3 commits into from
Mar 14, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,16 @@ fn usage(verbose: bool, include_unstable_options: bool) {
verbose_help);
}

fn print_wall_help() {
println!("
The flag -Wall does not exist in rustc. Most useful lints are enabled by default.
Use `rustc -W help` to see all available lints. The most used lints that are not
enabled by default covered by -Wunused; however, the best practice is to put
warning settings in the crate root using `#![warn(unused)]` instead of using
the command line flag directly.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with the feature. I would like to have a native speaker take a look over this. cc @rust-lang/docs

Maybe something closer to:

The flag `-Wall` does not exist in `rustc`. Most useful lints are enabled by default.
Use `rustc -W help` to see all available lints. The most used lints that are not
enabled by default are covered by `-Wunused`; however, the best practice is to
put warning settings in the crate root using `#![warn(LINT_NAME)]` instead of using
the command line flag directly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The most used lints that are not enabled by default are covered by -Wunused

Is there any particular reason why -Wunused is being called out here? Why unused vs. other lint checks?

the best practice is to put warning settings...

I might say "it's more common to put warning settings...", but I don't feel strongly

Other than that, seems good to me 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused turns on half of the allowed-by-default lints that I've ever seen used:

  • unused-qualifications
  • unused-results
  • unused-import-braces
  • unused-extern-crates

The others that I've personally seen used are:

  • missing-docs
  • trivial-casts
  • trivial-numeric-casts
  • unreachable-pub

And given that a LOT of crates in the ecosystem have #![warn(unused)], I thought it was the most relevant one to mention.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, looking at the -W help output, -Wunused only turns on unused-extern-crates... I thought it did all the unused-* lints?
I might have to go step-up my #![warn(unused-*)] lines in my projects.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, looking at the -W help output, -Wunused only turns on unused-extern-crates

taken from rustc -W help

Lint groups provided by rustc:

                   name  sub-lints
                   ----  ---------
               warnings  all lints that are set to issue warnings
              bad-style  non-camel-case-types, non-snake-case, non-upper-case-globals
    future-incompatible  private-in-public, pub-use-of-private-extern-crate, patterns-in-fns-without-body, safe-extern-statics, invalid-type-param-default, legacy-directory-ownership, legacy-imports, legacy-constructor-visibility, resolve-trait-on-defaulted-unit, missing-fragment-specifier, illegal-floating-point-literal-pattern, anonymous-parameters, parenthesized-params-in-types-and-modules, late-bound-lifetime-arguments, safe-packed-borrows, incoherent-fundamental-impls, coerce-never, tyvar-behind-raw-pointer
                 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, unused-allocation, unused-doc-comment, unused-extern-crates, unused-features, unused-parens


Compiler plugins can provide additional lints and lint groups. To see a listing of these, re-run `rustc -W help` with a crate filename.

");
}

fn describe_lints(sess: &Session, lint_store: &lint::LintStore, loaded_plugins: bool) {
println!("
Available lint options:
Expand Down Expand Up @@ -1380,6 +1390,13 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
return None;
}

// Handle the special case of -Wall.
let wall = matches.opt_strs("W");
if wall.iter().any(|x| *x == "all") {
print_wall_help();
return None;
}

// Don't handle -W help here, because we might first load plugins.
let r = matches.opt_strs("Z");
if r.iter().any(|x| *x == "help") {
Expand Down