Skip to content

Commit c97c7bf

Browse files
committed
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.
1 parent c933440 commit c97c7bf

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/librustc_driver/lib.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,16 @@ fn usage(verbose: bool, include_unstable_options: bool) {
11361136
verbose_help);
11371137
}
11381138

1139+
fn print_wall_help() {
1140+
println!("
1141+
The flag -Wall does not exist in rustc. Most useful lints are enabled by default.
1142+
Use `rustc -W help` to see all available lints. The most used lints that are not
1143+
enabled by default covered by -Wunused; however, the best practice is to put
1144+
warning settings in the crate root using `#![warn(unused)]` instead of using
1145+
the command line flag directly.
1146+
");
1147+
}
1148+
11391149
fn describe_lints(sess: &Session, lint_store: &lint::LintStore, loaded_plugins: bool) {
11401150
println!("
11411151
Available lint options:
@@ -1379,6 +1389,13 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
13791389
nightly_options::is_unstable_enabled(&matches));
13801390
return None;
13811391
}
1392+
1393+
// Handle the special case of -Wall.
1394+
let wall = matches.opt_strs("W");
1395+
if wall.iter().any(|x| *x == "all") {
1396+
print_wall_help();
1397+
return None;
1398+
}
13821399

13831400
// Don't handle -W help here, because we might first load plugins.
13841401
let r = matches.opt_strs("Z");

0 commit comments

Comments
 (0)