Skip to content

Commit

Permalink
Remove unused attribute in test
Browse files Browse the repository at this point in the history
  • Loading branch information
tesuji committed Sep 26, 2019
1 parent 08ce6bc commit 5639639
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 29 deletions.
13 changes: 6 additions & 7 deletions tests/ui/toplevel_ref_arg.fixed
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
// run-rustfix

#![warn(clippy::toplevel_ref_arg)]
#![allow(unused)]

fn main() {
// Closures should not warn
let y = |ref x| println!("{:?}", x);
y(1u8);

let x = &1;
let _x = &1;

let y: &(&_, u8) = &(&1, 2);
let _y: &(&_, u8) = &(&1, 2);

let z = &(1 + 2);
let _z = &(1 + 2);

let z = &mut (1 + 2);
let _z = &mut (1 + 2);

let (ref x, _) = (1, 2); // ok, not top level
println!("The answer is {}.", x);

let x = &vec![1, 2, 3];
let _x = &vec![1, 2, 3];

// Make sure that allowing the lint works
#[allow(clippy::toplevel_ref_arg)]
let ref mut x = 1_234_543;
let ref mut _x = 1_234_543;
}
13 changes: 6 additions & 7 deletions tests/ui/toplevel_ref_arg.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
// run-rustfix

#![warn(clippy::toplevel_ref_arg)]
#![allow(unused)]

fn main() {
// Closures should not warn
let y = |ref x| println!("{:?}", x);
y(1u8);

let ref x = 1;
let ref _x = 1;

let ref y: (&_, u8) = (&1, 2);
let ref _y: (&_, u8) = (&1, 2);

let ref z = 1 + 2;
let ref _z = 1 + 2;

let ref mut z = 1 + 2;
let ref mut _z = 1 + 2;

let (ref x, _) = (1, 2); // ok, not top level
println!("The answer is {}.", x);

let ref x = vec![1, 2, 3];
let ref _x = vec![1, 2, 3];

// Make sure that allowing the lint works
#[allow(clippy::toplevel_ref_arg)]
let ref mut x = 1_234_543;
let ref mut _x = 1_234_543;
}
30 changes: 15 additions & 15 deletions tests/ui/toplevel_ref_arg.stderr
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead
--> $DIR/toplevel_ref_arg.rs:11:9
--> $DIR/toplevel_ref_arg.rs:10:9
|
LL | let ref x = 1;
| ----^^^^^----- help: try: `let x = &1;`
LL | let ref _x = 1;
| ----^^^^^^----- help: try: `let _x = &1;`
|
= note: `-D clippy::toplevel-ref-arg` implied by `-D warnings`

error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead
--> $DIR/toplevel_ref_arg.rs:13:9
--> $DIR/toplevel_ref_arg.rs:12:9
|
LL | let ref y: (&_, u8) = (&1, 2);
| ----^^^^^--------------------- help: try: `let y: &(&_, u8) = &(&1, 2);`
LL | let ref _y: (&_, u8) = (&1, 2);
| ----^^^^^^--------------------- help: try: `let _y: &(&_, u8) = &(&1, 2);`

error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead
--> $DIR/toplevel_ref_arg.rs:15:9
--> $DIR/toplevel_ref_arg.rs:14:9
|
LL | let ref z = 1 + 2;
| ----^^^^^--------- help: try: `let z = &(1 + 2);`
LL | let ref _z = 1 + 2;
| ----^^^^^^--------- help: try: `let _z = &(1 + 2);`

error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead
--> $DIR/toplevel_ref_arg.rs:17:9
--> $DIR/toplevel_ref_arg.rs:16:9
|
LL | let ref mut z = 1 + 2;
| ----^^^^^^^^^--------- help: try: `let z = &mut (1 + 2);`
LL | let ref mut _z = 1 + 2;
| ----^^^^^^^^^^--------- help: try: `let _z = &mut (1 + 2);`

error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead
--> $DIR/toplevel_ref_arg.rs:22:9
--> $DIR/toplevel_ref_arg.rs:21:9
|
LL | let ref x = vec![1, 2, 3];
| ----^^^^^----------------- help: try: `let x = &vec![1, 2, 3];`
LL | let ref _x = vec![1, 2, 3];
| ----^^^^^^----------------- help: try: `let _x = &vec![1, 2, 3];`

error: aborting due to 5 previous errors

0 comments on commit 5639639

Please sign in to comment.