about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGeoff Hill <geoff@geoffhill.org>2013-10-08 18:26:09 -0700
committerGeoff Hill <geoff@geoffhill.org>2013-10-09 00:14:35 -0700
commit9c849825314f5d4ae7c3dcb5a69895e9f8ed847b (patch)
treec3bcb52aa311a0ecb2250c836989eea81481d372
parent3a70df1d3cf12eae47536a96e26c1e7e0030b75a (diff)
downloadrust-9c849825314f5d4ae7c3dcb5a69895e9f8ed847b.tar.gz
rust-9c849825314f5d4ae7c3dcb5a69895e9f8ed847b.zip
Change default lint output format.
Since lint check attributes are the preferred way of selectively
enabling/disabling lint checks, the output format of a failed
default check has been changed to reflect that.

When lint checks are being explicitly set by a command-line flag
or an attribute, the behavior is unchanged, so that the user can
quickly pinpoint the source.

Closes #6580
-rw-r--r--src/librustc/middle/lint.rs14
-rw-r--r--src/test/compile-fail/lint-output-format.rs32
2 files changed, 41 insertions, 5 deletions
diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs
index a44223fba83..d20917a47c3 100644
--- a/src/librustc/middle/lint.rs
+++ b/src/librustc/middle/lint.rs
@@ -1,4 +1,4 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -372,12 +372,16 @@ impl Context {
 
         let mut note = None;
         let msg = match src {
-            Default | CommandLine => {
-                format!("{} [-{} {}{}]", msg, match level {
+            Default => {
+                format!("{}, \\#[{}({})] on by default", msg,
+                    level_to_str(level), self.lint_to_str(lint))
+            },
+            CommandLine => {
+                format!("{} [-{} {}]", msg,
+                    match level {
                         warn => 'W', deny => 'D', forbid => 'F',
                         allow => fail2!()
-                    }, self.lint_to_str(lint).replace("_", "-"),
-                    if src == Default { " (default)" } else { "" })
+                    }, self.lint_to_str(lint).replace("_", "-"))
             },
             Node(src) => {
                 note = Some(src);
diff --git a/src/test/compile-fail/lint-output-format.rs b/src/test/compile-fail/lint-output-format.rs
new file mode 100644
index 00000000000..ba4cf5d17fb
--- /dev/null
+++ b/src/test/compile-fail/lint-output-format.rs
@@ -0,0 +1,32 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-flags:-F experimental -D unstable
+
+#[deprecated]
+fn foo() -> uint {
+    20
+}
+
+#[experimental]
+fn bar() -> uint {
+    40
+}
+
+#[unstable]
+fn baz() -> uint {
+    30
+}
+
+fn main() {
+    let _x = foo(); //~ WARNING #[warn(deprecated)] on by default
+    let _y = bar(); //~ ERROR [-F experimental]
+    let _z = baz(); //~ ERROR [-D unstable]
+}