about summary refs log tree commit diff
path: root/src/rustc/driver
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2012-04-12 17:30:52 -0700
committerGraydon Hoare <graydon@mozilla.com>2012-04-12 17:31:49 -0700
commit8a7fd4a04fa9683b149eb1db973d4e2c0f3d05cc (patch)
treeab41bc0cb3b9d8df784f0ae108a73bcb17328333 /src/rustc/driver
parent7b3cb05311ef7d671b0bf92b041112ef141dc188 (diff)
downloadrust-8a7fd4a04fa9683b149eb1db973d4e2c0f3d05cc.tar.gz
rust-8a7fd4a04fa9683b149eb1db973d4e2c0f3d05cc.zip
Support general warnings and errors in lint pass via flags and attrs. Close #1543.
Diffstat (limited to 'src/rustc/driver')
-rw-r--r--src/rustc/driver/driver.rs23
-rw-r--r--src/rustc/driver/rustc.rs9
-rw-r--r--src/rustc/driver/session.rs5
3 files changed, 21 insertions, 16 deletions
diff --git a/src/rustc/driver/driver.rs b/src/rustc/driver/driver.rs
index 8a5a88d91fa..20cd84d4078 100644
--- a/src/rustc/driver/driver.rs
+++ b/src/rustc/driver/driver.rs
@@ -366,10 +366,16 @@ fn build_session_options(match: getopts::match,
 
     let parse_only = opt_present(match, "parse-only");
     let no_trans = opt_present(match, "no-trans");
-    let mut lint_opts = [];
-    if opt_present(match, "no-lint-ctypes") {
-        lint_opts += [(lint::ctypes, false)];
-    }
+
+    let lint_flags = (getopts::opt_strs(match, "W")
+                      + getopts::opt_strs(match, "warn"));
+    let lint_dict = lint::get_lint_dict();
+    let lint_opts = vec::map(lint_flags) {|flag|
+        alt lint::lookup_lint(lint_dict, flag) {
+          none { early_error(demitter, #fmt("unknown warning: %s", flag)) }
+          some(x) { x }
+        }
+    };
 
     let output_type =
         if parse_only || no_trans {
@@ -426,7 +432,6 @@ fn build_session_options(match: getopts::match,
     let addl_lib_search_paths = getopts::opt_strs(match, "L");
     let cfg = parse_cfgspecs(getopts::opt_strs(match, "cfg"));
     let test = opt_present(match, "test");
-    let warn_unused_imports = opt_present(match, "warn-unused-imports");
     let sopts: @session::options =
         @{crate_type: crate_type,
           static: static,
@@ -448,8 +453,7 @@ fn build_session_options(match: getopts::match,
           test: test,
           parse_only: parse_only,
           no_trans: no_trans,
-          no_asm_comments: no_asm_comments,
-          warn_unused_imports: warn_unused_imports};
+          no_asm_comments: no_asm_comments};
     ret sopts;
 }
 
@@ -521,11 +525,12 @@ fn opts() -> [getopts::opt] {
          optflag("time-passes"), optflag("time-llvm-passes"),
          optflag("count-llvm-insns"),
          optflag("no-verify"),
-         optflag("no-lint-ctypes"),
+
+         optmulti("W"), optmulti("warn"),
+
          optmulti("cfg"), optflag("test"),
          optflag("lib"), optflag("bin"), optflag("static"), optflag("gc"),
          optflag("no-asm-comments"),
-         optflag("warn-unused-imports"),
          optflag("enforce-mut-vars")];
 }
 
diff --git a/src/rustc/driver/rustc.rs b/src/rustc/driver/rustc.rs
index dc3386acb73..0654691242a 100644
--- a/src/rustc/driver/rustc.rs
+++ b/src/rustc/driver/rustc.rs
@@ -39,7 +39,6 @@ Options:
     --lib              Compile a library crate
     --ls               List the symbols defined by a compiled library crate
     --no-asm-comments  Do not add comments into the assembly source
-    --no-lint-ctypes   Suppress warnings for possibly incorrect ctype usage
     --no-trans         Run all passes except translation; no output
     --no-verify        Suppress LLVM verification step (slight speedup)
                        (see http://llvm.org/docs/Passes.html for detail)
@@ -65,13 +64,15 @@ Options:
                        (see http://sources.redhat.com/autobook/autobook/
                        autobook_17.html for detail)
 
+    -W <foo>           enable warning <foo>
+    -W no-<foo>        disable warning <foo>
+    -W err-<foo>       enable warning <foo> as an error
+
     --time-passes      Time the individual phases of the compiler
     --time-llvm-passes Time the individual phases of the LLVM backend
     --count-llvm-insns Count and categorize generated LLVM instructions
-    -v --version       Print version info and exit
-    --warn-unused-imports
-                       Warn about unnecessary imports
 
+    -v --version       Print version info and exit
 ");
 }
 
diff --git a/src/rustc/driver/session.rs b/src/rustc/driver/session.rs
index 03675b74d1b..af978db1a77 100644
--- a/src/rustc/driver/session.rs
+++ b/src/rustc/driver/session.rs
@@ -31,7 +31,7 @@ type options =
      debuginfo: bool,
      extra_debuginfo: bool,
      verify: bool,
-     lint_opts: [(lint::option, bool)],
+     lint_opts: [(lint::lint, lint::level)],
      save_temps: bool,
      stats: bool,
      time_passes: bool,
@@ -45,8 +45,7 @@ type options =
      test: bool,
      parse_only: bool,
      no_trans: bool,
-     no_asm_comments: bool,
-     warn_unused_imports: bool};
+     no_asm_comments: bool};
 
 type crate_metadata = {name: str, data: [u8]};