Skip to content

Commit 24b3a6c

Browse files
committed
---
yaml --- r: 15655 b: refs/heads/try c: 6157558 h: refs/heads/master i: 15653: 0f2e930 15651: c79c172 15647: c681d57 v: v3
1 parent c3f7d1e commit 24b3a6c

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 7eec6eb2bba04ee8cd46df7c640abab4610cd4b7
5+
refs/heads/try: 61575582ba853cd4ebf406cb7f8024bdf17fecfc
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rustc/driver/rustc.rs

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,24 @@ import core::*;
99
// -*- rust -*-
1010
import result::{ok, err};
1111
import std::getopts;
12-
import io::writer_util;
12+
import std::map::hashmap;
1313
import getopts::{opt_present};
1414
import rustc::driver::driver::*;
1515
import rustc::syntax::codemap;
1616
import rustc::driver::diagnostic;
17+
import rustc::middle::lint;
1718

1819
fn version(argv0: str) {
1920
let mut vers = "unknown version";
2021
let env_vers = #env["CFG_VERSION"];
2122
if str::len(env_vers) != 0u { vers = env_vers; }
22-
io::stdout().write_str(#fmt["%s %s\n", argv0, vers]);
23-
io::stdout().write_str(#fmt["host: %s\n", host_triple()]);
23+
io::println(#fmt("%s %s", argv0, vers));
24+
io::println(#fmt("host: %s", host_triple()));
2425
}
2526

2627
fn usage(argv0: str) {
27-
io::stdout().write_str(#fmt["Usage: %s [options] <input>\n", argv0] +
28-
"
28+
io::println(#fmt("Usage: %s [options] <input>\n", argv0) +
29+
"
2930
Options:
3031
3132
--bin Compile an executable crate (default)
@@ -70,6 +71,8 @@ Options:
7071
-W no-<foo> disable warning <foo>
7172
-W err-<foo> enable warning <foo> as an error
7273
74+
-W help Print available warnings and default settings
75+
7376
--time-passes Time the individual phases of the compiler
7477
--time-llvm-passes Time the individual phases of the LLVM backend
7578
--count-llvm-insns Count and categorize generated LLVM instructions
@@ -78,6 +81,30 @@ Options:
7881
");
7982
}
8083

84+
fn describe_warnings() {
85+
let lint_dict = lint::get_lint_dict();
86+
let mut max_key = 0u;
87+
for lint_dict.each_key {|k| max_key = uint::max(k.len(), max_key); }
88+
fn padded(max: uint, s: str) -> str {
89+
str::from_bytes(vec::from_elem(max - s.len(), ' ' as u8)) + s
90+
}
91+
io::println(#fmt("\nAvailable warnings:\n"));
92+
io::println(#fmt(" %s %7.7s %s",
93+
padded(max_key, "name"), "default", "meaning"));
94+
io::println(#fmt(" %s %7.7s %s\n",
95+
padded(max_key, "----"), "-------", "-------"));
96+
for lint_dict.each {|k, v|
97+
let k = str::replace(k, "_", "-");
98+
io::println(#fmt(" %s %7.7s %s",
99+
padded(max_key, k),
100+
alt v.default { lint::warn { "warn" }
101+
lint::error { "error" }
102+
lint::ignore { "ignore" } },
103+
v.desc));
104+
}
105+
io::println("");
106+
}
107+
81108
fn run_compiler(args: [str], demitter: diagnostic::emitter) {
82109
// Don't display log spew by default. Can override with RUST_LOG.
83110
logging::console_off();
@@ -94,10 +121,19 @@ fn run_compiler(args: [str], demitter: diagnostic::emitter) {
94121
early_error(demitter, getopts::fail_str(f))
95122
}
96123
};
124+
97125
if opt_present(match, "h") || opt_present(match, "help") {
98126
usage(binary);
99127
ret;
100128
}
129+
130+
let lint_flags = (getopts::opt_strs(match, "W")
131+
+ getopts::opt_strs(match, "warn"));
132+
if lint_flags.contains("help") {
133+
describe_warnings();
134+
ret;
135+
}
136+
101137
if opt_present(match, "v") || opt_present(match, "version") {
102138
version(binary);
103139
ret;

0 commit comments

Comments
 (0)