about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
authorZack M. Davis <code@zackmdavis.net>2017-09-29 23:52:51 -0700
committerZack M. Davis <code@zackmdavis.net>2017-09-30 11:31:12 -0700
commite3b498971dfb5009f15700d103c88a6c427edd30 (patch)
tree7d591f8ba63fc30d458eccda7629ebf82751e36a /src/test/ui
parent5c9f806d7860a281346743b31529230d5480deef (diff)
downloadrust-e3b498971dfb5009f15700d103c88a6c427edd30.tar.gz
rust-e3b498971dfb5009f15700d103c88a6c427edd30.zip
code suggestions for unused-mut, while-true lints; UI test
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/lint/suggestions.rs20
-rw-r--r--src/test/ui/lint/suggestions.stderr45
-rw-r--r--src/test/ui/path-lookahead.stderr2
3 files changed, 66 insertions, 1 deletions
diff --git a/src/test/ui/lint/suggestions.rs b/src/test/ui/lint/suggestions.rs
new file mode 100644
index 00000000000..874124a7d36
--- /dev/null
+++ b/src/test/ui/lint/suggestions.rs
@@ -0,0 +1,20 @@
+// Copyright 2017 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.
+
+#![warn(unused_mut)] // UI tests pass `-A unused`—see Issue #43896
+#![feature(no_debug)]
+
+#[no_debug] // should suggest removal of deprecated attribute
+fn main() {
+    while true { // should suggest `loop`
+        let mut a = (1); // should suggest no `mut`, no parens
+        println!("{}", a);
+    }
+}
diff --git a/src/test/ui/lint/suggestions.stderr b/src/test/ui/lint/suggestions.stderr
new file mode 100644
index 00000000000..5b2a4f589f7
--- /dev/null
+++ b/src/test/ui/lint/suggestions.stderr
@@ -0,0 +1,45 @@
+warning: unnecessary parentheses around assigned value
+  --> $DIR/suggestions.rs:17:21
+   |
+17 |         let mut a = (1); // should suggest no `mut`, no parens
+   |                     ^^^ help: remove these parentheses
+   |
+   = note: #[warn(unused_parens)] on by default
+
+warning: use of deprecated attribute `no_debug`: the `#[no_debug]` attribute was an experimental feature that has been deprecated due to lack of demand. See https://github.com/rust-lang/rust/issues/29721
+  --> $DIR/suggestions.rs:14:1
+   |
+14 | #[no_debug] // should suggest removal of deprecated attribute
+   | ^^^^^^^^^^^ help: remove this attribute
+   |
+   = note: #[warn(deprecated)] on by default
+
+warning: denote infinite loops with `loop { ... }`
+  --> $DIR/suggestions.rs:16:5
+   |
+16 |       while true { // should suggest `loop`
+   |       ^---------
+   |       |
+   |  _____help: use `loop`
+   | |
+17 | |         let mut a = (1); // should suggest no `mut`, no parens
+18 | |         println!("{}", a);
+19 | |     }
+   | |_____^
+   |
+   = note: #[warn(while_true)] on by default
+
+warning: variable does not need to be mutable
+  --> $DIR/suggestions.rs:17:13
+   |
+17 |         let mut a = (1); // should suggest no `mut`, no parens
+   |             ---^^
+   |             |
+   |             help: remove this `mut`
+   |
+note: lint level defined here
+  --> $DIR/suggestions.rs:11:9
+   |
+11 | #![warn(unused_mut)] // UI tests pass `-A unused`—see Issue #43896
+   |         ^^^^^^^^^^
+
diff --git a/src/test/ui/path-lookahead.stderr b/src/test/ui/path-lookahead.stderr
index 1d4ab35046b..19e22b3f6f9 100644
--- a/src/test/ui/path-lookahead.stderr
+++ b/src/test/ui/path-lookahead.stderr
@@ -2,7 +2,7 @@ warning: unnecessary parentheses around `return` value
   --> $DIR/path-lookahead.rs:18:10
    |
 18 |   return (<T as ToString>::to_string(&arg)); //~WARN unnecessary parentheses around `return` value
-   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove these parentheses
    |
    = note: #[warn(unused_parens)] on by default