Skip to content

Commit 4ea78d4

Browse files
committed
Rollup merge of rust-lang#48765 - Phlosioneer:10234-wall-help-message, 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.
2 parents d089fe9 + c1337cd commit 4ea78d4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/librustc_driver/lib.rs

+16
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,15 @@ fn usage(verbose: bool, include_unstable_options: bool) {
11471147
verbose_help);
11481148
}
11491149

1150+
fn print_wall_help() {
1151+
println!("
1152+
The flag `-Wall` does not exist in `rustc`. Most useful lints are enabled by
1153+
default. Use `rustc -W help` to see all available lints. It's more common to put
1154+
warning settings in the crate root using `#![warn(LINT_NAME)]` instead of using
1155+
the command line flag directly.
1156+
");
1157+
}
1158+
11501159
fn describe_lints(sess: &Session, lint_store: &lint::LintStore, loaded_plugins: bool) {
11511160
println!("
11521161
Available lint options:
@@ -1391,6 +1400,13 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
13911400
return None;
13921401
}
13931402

1403+
// Handle the special case of -Wall.
1404+
let wall = matches.opt_strs("W");
1405+
if wall.iter().any(|x| *x == "all") {
1406+
print_wall_help();
1407+
return None;
1408+
}
1409+
13941410
// Don't handle -W help here, because we might first load plugins.
13951411
let r = matches.opt_strs("Z");
13961412
if r.iter().any(|x| *x == "help") {

0 commit comments

Comments
 (0)