Skip to content

Commit

Permalink
Allow this lint on lint tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hkmatsumoto committed Oct 18, 2020
1 parent 8be8a1e commit 97868e3
Show file tree
Hide file tree
Showing 40 changed files with 183 additions and 159 deletions.
1 change: 1 addition & 0 deletions tests/ui/derive_ord_xor_partial_ord.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(clippy::derive_ord_xor_partial_ord)]
#![allow(clippy::unnecessary_wrap)]

use std::cmp::Ordering;

Expand Down
16 changes: 8 additions & 8 deletions tests/ui/derive_ord_xor_partial_ord.stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
error: you are deriving `Ord` but have implemented `PartialOrd` explicitly
--> $DIR/derive_ord_xor_partial_ord.rs:20:10
--> $DIR/derive_ord_xor_partial_ord.rs:21:10
|
LL | #[derive(Ord, PartialEq, Eq)]
| ^^^
|
= note: `-D clippy::derive-ord-xor-partial-ord` implied by `-D warnings`
note: `PartialOrd` implemented here
--> $DIR/derive_ord_xor_partial_ord.rs:23:1
--> $DIR/derive_ord_xor_partial_ord.rs:24:1
|
LL | / impl PartialOrd for DeriveOrd {
LL | | fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Expand All @@ -17,13 +17,13 @@ LL | | }
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: you are deriving `Ord` but have implemented `PartialOrd` explicitly
--> $DIR/derive_ord_xor_partial_ord.rs:29:10
--> $DIR/derive_ord_xor_partial_ord.rs:30:10
|
LL | #[derive(Ord, PartialEq, Eq)]
| ^^^
|
note: `PartialOrd` implemented here
--> $DIR/derive_ord_xor_partial_ord.rs:32:1
--> $DIR/derive_ord_xor_partial_ord.rs:33:1
|
LL | / impl PartialOrd<DeriveOrdWithExplicitTypeVariable> for DeriveOrdWithExplicitTypeVariable {
LL | | fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Expand All @@ -34,7 +34,7 @@ LL | | }
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: you are implementing `Ord` explicitly but have derived `PartialOrd`
--> $DIR/derive_ord_xor_partial_ord.rs:41:1
--> $DIR/derive_ord_xor_partial_ord.rs:42:1
|
LL | / impl std::cmp::Ord for DerivePartialOrd {
LL | | fn cmp(&self, other: &Self) -> Ordering {
Expand All @@ -44,14 +44,14 @@ LL | | }
| |_^
|
note: `PartialOrd` implemented here
--> $DIR/derive_ord_xor_partial_ord.rs:38:10
--> $DIR/derive_ord_xor_partial_ord.rs:39:10
|
LL | #[derive(PartialOrd, PartialEq, Eq)]
| ^^^^^^^^^^
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: you are implementing `Ord` explicitly but have derived `PartialOrd`
--> $DIR/derive_ord_xor_partial_ord.rs:61:5
--> $DIR/derive_ord_xor_partial_ord.rs:62:5
|
LL | / impl Ord for DerivePartialOrdInUseOrd {
LL | | fn cmp(&self, other: &Self) -> Ordering {
Expand All @@ -61,7 +61,7 @@ LL | | }
| |_____^
|
note: `PartialOrd` implemented here
--> $DIR/derive_ord_xor_partial_ord.rs:58:14
--> $DIR/derive_ord_xor_partial_ord.rs:59:14
|
LL | #[derive(PartialOrd, PartialEq, Eq)]
| ^^^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions tests/ui/doc_errors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// edition:2018
#![warn(clippy::missing_errors_doc)]
#![allow(clippy::result_unit_err)]
#![allow(clippy::unnecessary_wrap)]

use std::io;

Expand Down
1 change: 1 addition & 0 deletions tests/ui/drop_ref.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![warn(clippy::drop_ref)]
#![allow(clippy::toplevel_ref_arg)]
#![allow(clippy::map_err_ignore)]
#![allow(clippy::unnecessary_wrap)]

use std::mem::drop;

Expand Down
1 change: 1 addition & 0 deletions tests/ui/forget_ref.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![warn(clippy::forget_ref)]
#![allow(clippy::toplevel_ref_arg)]
#![allow(clippy::unnecessary_wrap)]

use std::mem::forget;

Expand Down
36 changes: 18 additions & 18 deletions tests/ui/forget_ref.stderr
Original file line number Diff line number Diff line change
@@ -1,108 +1,108 @@
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
--> $DIR/forget_ref.rs:9:5
--> $DIR/forget_ref.rs:10:5
|
LL | forget(&SomeStruct);
| ^^^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::forget-ref` implied by `-D warnings`
note: argument has type `&SomeStruct`
--> $DIR/forget_ref.rs:9:12
--> $DIR/forget_ref.rs:10:12
|
LL | forget(&SomeStruct);
| ^^^^^^^^^^^

error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
--> $DIR/forget_ref.rs:12:5
--> $DIR/forget_ref.rs:13:5
|
LL | forget(&owned);
| ^^^^^^^^^^^^^^
|
note: argument has type `&SomeStruct`
--> $DIR/forget_ref.rs:12:12
--> $DIR/forget_ref.rs:13:12
|
LL | forget(&owned);
| ^^^^^^

error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
--> $DIR/forget_ref.rs:13:5
--> $DIR/forget_ref.rs:14:5
|
LL | forget(&&owned);
| ^^^^^^^^^^^^^^^
|
note: argument has type `&&SomeStruct`
--> $DIR/forget_ref.rs:13:12
--> $DIR/forget_ref.rs:14:12
|
LL | forget(&&owned);
| ^^^^^^^

error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
--> $DIR/forget_ref.rs:14:5
--> $DIR/forget_ref.rs:15:5
|
LL | forget(&mut owned);
| ^^^^^^^^^^^^^^^^^^
|
note: argument has type `&mut SomeStruct`
--> $DIR/forget_ref.rs:14:12
--> $DIR/forget_ref.rs:15:12
|
LL | forget(&mut owned);
| ^^^^^^^^^^

error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
--> $DIR/forget_ref.rs:18:5
--> $DIR/forget_ref.rs:19:5
|
LL | forget(&*reference1);
| ^^^^^^^^^^^^^^^^^^^^
|
note: argument has type `&SomeStruct`
--> $DIR/forget_ref.rs:18:12
--> $DIR/forget_ref.rs:19:12
|
LL | forget(&*reference1);
| ^^^^^^^^^^^^

error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
--> $DIR/forget_ref.rs:21:5
--> $DIR/forget_ref.rs:22:5
|
LL | forget(reference2);
| ^^^^^^^^^^^^^^^^^^
|
note: argument has type `&mut SomeStruct`
--> $DIR/forget_ref.rs:21:12
--> $DIR/forget_ref.rs:22:12
|
LL | forget(reference2);
| ^^^^^^^^^^

error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
--> $DIR/forget_ref.rs:24:5
--> $DIR/forget_ref.rs:25:5
|
LL | forget(reference3);
| ^^^^^^^^^^^^^^^^^^
|
note: argument has type `&SomeStruct`
--> $DIR/forget_ref.rs:24:12
--> $DIR/forget_ref.rs:25:12
|
LL | forget(reference3);
| ^^^^^^^^^^

error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
--> $DIR/forget_ref.rs:29:5
--> $DIR/forget_ref.rs:30:5
|
LL | forget(&val);
| ^^^^^^^^^^^^
|
note: argument has type `&T`
--> $DIR/forget_ref.rs:29:12
--> $DIR/forget_ref.rs:30:12
|
LL | forget(&val);
| ^^^^

error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
--> $DIR/forget_ref.rs:37:5
--> $DIR/forget_ref.rs:38:5
|
LL | std::mem::forget(&SomeStruct);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: argument has type `&SomeStruct`
--> $DIR/forget_ref.rs:37:22
--> $DIR/forget_ref.rs:38:22
|
LL | std::mem::forget(&SomeStruct);
| ^^^^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions tests/ui/let_underscore_must_use.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(clippy::let_underscore_must_use)]
#![allow(clippy::unnecessary_wrap)]

// Debug implementations can fire this lint,
// so we shouldn't lint external macros
Expand Down
24 changes: 12 additions & 12 deletions tests/ui/let_underscore_must_use.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: non-binding let on a result of a `#[must_use]` function
--> $DIR/let_underscore_must_use.rs:66:5
--> $DIR/let_underscore_must_use.rs:67:5
|
LL | let _ = f();
| ^^^^^^^^^^^^
Expand All @@ -8,87 +8,87 @@ LL | let _ = f();
= help: consider explicitly using function result

error: non-binding let on an expression with `#[must_use]` type
--> $DIR/let_underscore_must_use.rs:67:5
--> $DIR/let_underscore_must_use.rs:68:5
|
LL | let _ = g();
| ^^^^^^^^^^^^
|
= help: consider explicitly using expression value

error: non-binding let on a result of a `#[must_use]` function
--> $DIR/let_underscore_must_use.rs:69:5
--> $DIR/let_underscore_must_use.rs:70:5
|
LL | let _ = l(0_u32);
| ^^^^^^^^^^^^^^^^^
|
= help: consider explicitly using function result

error: non-binding let on a result of a `#[must_use]` function
--> $DIR/let_underscore_must_use.rs:73:5
--> $DIR/let_underscore_must_use.rs:74:5
|
LL | let _ = s.f();
| ^^^^^^^^^^^^^^
|
= help: consider explicitly using function result

error: non-binding let on an expression with `#[must_use]` type
--> $DIR/let_underscore_must_use.rs:74:5
--> $DIR/let_underscore_must_use.rs:75:5
|
LL | let _ = s.g();
| ^^^^^^^^^^^^^^
|
= help: consider explicitly using expression value

error: non-binding let on a result of a `#[must_use]` function
--> $DIR/let_underscore_must_use.rs:77:5
--> $DIR/let_underscore_must_use.rs:78:5
|
LL | let _ = S::h();
| ^^^^^^^^^^^^^^^
|
= help: consider explicitly using function result

error: non-binding let on an expression with `#[must_use]` type
--> $DIR/let_underscore_must_use.rs:78:5
--> $DIR/let_underscore_must_use.rs:79:5
|
LL | let _ = S::p();
| ^^^^^^^^^^^^^^^
|
= help: consider explicitly using expression value

error: non-binding let on a result of a `#[must_use]` function
--> $DIR/let_underscore_must_use.rs:80:5
--> $DIR/let_underscore_must_use.rs:81:5
|
LL | let _ = S::a();
| ^^^^^^^^^^^^^^^
|
= help: consider explicitly using function result

error: non-binding let on an expression with `#[must_use]` type
--> $DIR/let_underscore_must_use.rs:82:5
--> $DIR/let_underscore_must_use.rs:83:5
|
LL | let _ = if true { Ok(()) } else { Err(()) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider explicitly using expression value

error: non-binding let on a result of a `#[must_use]` function
--> $DIR/let_underscore_must_use.rs:86:5
--> $DIR/let_underscore_must_use.rs:87:5
|
LL | let _ = a.is_ok();
| ^^^^^^^^^^^^^^^^^^
|
= help: consider explicitly using function result

error: non-binding let on an expression with `#[must_use]` type
--> $DIR/let_underscore_must_use.rs:88:5
--> $DIR/let_underscore_must_use.rs:89:5
|
LL | let _ = a.map(|_| ());
| ^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider explicitly using expression value

error: non-binding let on an expression with `#[must_use]` type
--> $DIR/let_underscore_must_use.rs:90:5
--> $DIR/let_underscore_must_use.rs:91:5
|
LL | let _ = a;
| ^^^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions tests/ui/map_flatten.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#![warn(clippy::all, clippy::pedantic)]
#![allow(clippy::missing_docs_in_private_items)]
#![allow(clippy::map_identity)]
#![allow(clippy::unnecessary_wrap)]

fn main() {
// mapping to Option on Iterator
Expand Down
1 change: 1 addition & 0 deletions tests/ui/map_flatten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#![warn(clippy::all, clippy::pedantic)]
#![allow(clippy::missing_docs_in_private_items)]
#![allow(clippy::map_identity)]
#![allow(clippy::unnecessary_wrap)]

fn main() {
// mapping to Option on Iterator
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/map_flatten.stderr
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
error: called `map(..).flatten()` on an `Iterator`
--> $DIR/map_flatten.rs:14:46
--> $DIR/map_flatten.rs:15:46
|
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id).flatten().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `filter_map` instead: `.filter_map(option_id)`
|
= note: `-D clippy::map-flatten` implied by `-D warnings`

error: called `map(..).flatten()` on an `Iterator`
--> $DIR/map_flatten.rs:15:46
--> $DIR/map_flatten.rs:16:46
|
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_ref).flatten().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `filter_map` instead: `.filter_map(option_id_ref)`

error: called `map(..).flatten()` on an `Iterator`
--> $DIR/map_flatten.rs:16:46
--> $DIR/map_flatten.rs:17:46
|
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_closure).flatten().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `filter_map` instead: `.filter_map(option_id_closure)`

error: called `map(..).flatten()` on an `Iterator`
--> $DIR/map_flatten.rs:17:46
--> $DIR/map_flatten.rs:18:46
|
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| x.checked_add(1)).flatten().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `filter_map` instead: `.filter_map(|x| x.checked_add(1))`

error: called `map(..).flatten()` on an `Iterator`
--> $DIR/map_flatten.rs:20:46
--> $DIR/map_flatten.rs:21:46
|
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| 0..x).flatten().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `flat_map` instead: `.flat_map(|x| 0..x)`

error: called `map(..).flatten()` on an `Option`
--> $DIR/map_flatten.rs:23:39
--> $DIR/map_flatten.rs:24:39
|
LL | let _: Option<_> = (Some(Some(1))).map(|x| x).flatten();
| ^^^^^^^^^^^^^^^^^^^^^ help: try using `and_then` instead: `.and_then(|x| x)`
Expand Down
Loading

0 comments on commit 97868e3

Please sign in to comment.