Skip to content

Commit

Permalink
Fix missing ui tests annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Aug 28, 2023
1 parent af2bb8b commit 42424fc
Show file tree
Hide file tree
Showing 576 changed files with 7,041 additions and 4,112 deletions.
3 changes: 3 additions & 0 deletions tests/ui/as_underscore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ fn foo(_n: usize) {}
fn main() {
let n: u16 = 256;
foo(n as _);
//~^ ERROR: using `as _` conversion
//~| NOTE: `-D clippy::as-underscore` implied by `-D warnings`

let n = 0_u128;
let _n: u8 = n as _;
//~^ ERROR: using `as _` conversion
}
2 changes: 1 addition & 1 deletion tests/ui/as_underscore.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LL | foo(n as _);
= note: `-D clippy::as-underscore` implied by `-D warnings`

error: using `as _` conversion
--> $DIR/as_underscore.rs:10:18
--> $DIR/as_underscore.rs:12:18
|
LL | let _n: u8 = n as _;
| ^^^^^-
Expand Down
8 changes: 8 additions & 0 deletions tests/ui/assertions_on_result_states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ fn main() {
let r: Result<Foo, DebugFoo> = Ok(Foo);
debug_assert!(r.is_ok());
assert!(r.is_ok());
//~^ ERROR: called `assert!` with `Result::is_ok`
//~| NOTE: `-D clippy::assertions-on-result-states` implied by `-D warnings`

// test ok with non-debug error type
let r: Result<Foo, Foo> = Ok(Foo);
Expand All @@ -40,9 +42,11 @@ fn main() {
Ok(Foo)
}
assert!(get_ok().is_ok());
//~^ ERROR: called `assert!` with `Result::is_ok`

// test macro ok
assert!(get_ok_macro!().is_ok());
//~^ ERROR: called `assert!` with `Result::is_ok`

// test ok that shouldn't be moved
let r: Result<CopyFoo, DebugFoo> = Ok(CopyFoo);
Expand All @@ -56,12 +60,14 @@ fn main() {
// test ok that is copied
let r: Result<CopyFoo, CopyFoo> = Ok(CopyFoo);
assert!(r.is_ok());
//~^ ERROR: called `assert!` with `Result::is_ok`
r.unwrap();

// test reference to ok
let r: Result<CopyFoo, CopyFoo> = Ok(CopyFoo);
fn test_ref_copy_ok(r: &Result<CopyFoo, CopyFoo>) {
assert!(r.is_ok());
//~^ ERROR: called `assert!` with `Result::is_ok`
}
test_ref_copy_ok(&r);
r.unwrap();
Expand All @@ -70,6 +76,7 @@ fn main() {
let r: Result<DebugFoo, Foo> = Err(Foo);
debug_assert!(r.is_err());
assert!(r.is_err());
//~^ ERROR: called `assert!` with `Result::is_err`

// test err with non-debug value type
let r: Result<Foo, Foo> = Err(Foo);
Expand All @@ -80,4 +87,5 @@ fn main() {
fn issue9450() {
let res: Result<i32, i32> = Ok(1);
assert!(res.is_err())
//~^ ERROR: called `assert!` with `Result::is_err`
}
12 changes: 6 additions & 6 deletions tests/ui/assertions_on_result_states.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,37 @@ LL | assert!(r.is_ok());
= note: `-D clippy::assertions-on-result-states` implied by `-D warnings`

error: called `assert!` with `Result::is_ok`
--> $DIR/assertions_on_result_states.rs:42:5
--> $DIR/assertions_on_result_states.rs:44:5
|
LL | assert!(get_ok().is_ok());
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `get_ok().unwrap()`

error: called `assert!` with `Result::is_ok`
--> $DIR/assertions_on_result_states.rs:45:5
--> $DIR/assertions_on_result_states.rs:48:5
|
LL | assert!(get_ok_macro!().is_ok());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `get_ok_macro!().unwrap()`

error: called `assert!` with `Result::is_ok`
--> $DIR/assertions_on_result_states.rs:58:5
--> $DIR/assertions_on_result_states.rs:62:5
|
LL | assert!(r.is_ok());
| ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()`

error: called `assert!` with `Result::is_ok`
--> $DIR/assertions_on_result_states.rs:64:9
--> $DIR/assertions_on_result_states.rs:69:9
|
LL | assert!(r.is_ok());
| ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()`

error: called `assert!` with `Result::is_err`
--> $DIR/assertions_on_result_states.rs:72:5
--> $DIR/assertions_on_result_states.rs:78:5
|
LL | assert!(r.is_err());
| ^^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap_err()`

error: called `assert!` with `Result::is_err`
--> $DIR/assertions_on_result_states.rs:82:5
--> $DIR/assertions_on_result_states.rs:89:5
|
LL | assert!(res.is_err())
| ^^^^^^^^^^^^^^^^^^^^^ help: replace with: `res.unwrap_err();`
Expand Down
12 changes: 12 additions & 0 deletions tests/ui/assign_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,37 @@ use core::num::Wrapping;
fn main() {
let mut a = 5;
a = a + 1;
//~^ ERROR: manual implementation of an assign operation
//~| NOTE: `-D clippy::assign-op-pattern` implied by `-D warnings`
a = 1 + a;
//~^ ERROR: manual implementation of an assign operation
a = a - 1;
//~^ ERROR: manual implementation of an assign operation
a = a * 99;
//~^ ERROR: manual implementation of an assign operation
a = 42 * a;
//~^ ERROR: manual implementation of an assign operation
a = a / 2;
//~^ ERROR: manual implementation of an assign operation
a = a % 5;
//~^ ERROR: manual implementation of an assign operation
a = a & 1;
//~^ ERROR: manual implementation of an assign operation
a = 1 - a;
a = 5 / a;
a = 42 % a;
a = 6 << a;
let mut s = String::new();
s = s + "bla";
//~^ ERROR: manual implementation of an assign operation

// Issue #9180
let mut a = Wrapping(0u32);
a = a + Wrapping(1u32);
//~^ ERROR: manual implementation of an assign operation
let mut v = vec![0u32, 1u32];
v[0] = v[0] + v[1];
//~^ ERROR: manual implementation of an assign operation
let mut v = vec![Wrapping(0u32), Wrapping(1u32)];
v[0] = v[0] + v[1];
let _ = || v[0] = v[0] + v[1];
Expand Down
20 changes: 10 additions & 10 deletions tests/ui/assign_ops.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,61 +7,61 @@ LL | a = a + 1;
= note: `-D clippy::assign-op-pattern` implied by `-D warnings`

error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:8:5
--> $DIR/assign_ops.rs:10:5
|
LL | a = 1 + a;
| ^^^^^^^^^ help: replace it with: `a += 1`

error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:9:5
--> $DIR/assign_ops.rs:12:5
|
LL | a = a - 1;
| ^^^^^^^^^ help: replace it with: `a -= 1`

error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:10:5
--> $DIR/assign_ops.rs:14:5
|
LL | a = a * 99;
| ^^^^^^^^^^ help: replace it with: `a *= 99`

error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:11:5
--> $DIR/assign_ops.rs:16:5
|
LL | a = 42 * a;
| ^^^^^^^^^^ help: replace it with: `a *= 42`

error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:12:5
--> $DIR/assign_ops.rs:18:5
|
LL | a = a / 2;
| ^^^^^^^^^ help: replace it with: `a /= 2`

error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:13:5
--> $DIR/assign_ops.rs:20:5
|
LL | a = a % 5;
| ^^^^^^^^^ help: replace it with: `a %= 5`

error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:14:5
--> $DIR/assign_ops.rs:22:5
|
LL | a = a & 1;
| ^^^^^^^^^ help: replace it with: `a &= 1`

error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:20:5
--> $DIR/assign_ops.rs:29:5
|
LL | s = s + "bla";
| ^^^^^^^^^^^^^ help: replace it with: `s += "bla"`

error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:24:5
--> $DIR/assign_ops.rs:34:5
|
LL | a = a + Wrapping(1u32);
| ^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `a += Wrapping(1u32)`

error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:26:5
--> $DIR/assign_ops.rs:37:5
|
LL | v[0] = v[0] + v[1];
| ^^^^^^^^^^^^^^^^^^ help: replace it with: `v[0] += v[1]`
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/async_yields_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,37 @@ fn main() {
};
let _h = async {
async {
//~^ ERROR: an async construct yields a type which is itself awaitable
//~| NOTE: `-D clippy::async-yields-async` implied by `-D warnings`
3
}
};
let _i = async {
CustomFutureType
//~^ ERROR: an async construct yields a type which is itself awaitable
};
let _i = async || {
3
};
let _j = async || {
async {
//~^ ERROR: an async construct yields a type which is itself awaitable
3
}
};
let _k = async || {
CustomFutureType
//~^ ERROR: an async construct yields a type which is itself awaitable
};
let _l = async || CustomFutureType;
//~^ ERROR: an async construct yields a type which is itself awaitable
let _m = async || {
println!("I'm bored");
// Some more stuff

// Finally something to await
CustomFutureType
//~^ ERROR: an async construct yields a type which is itself awaitable
};
let _n = async || custom_future_type_ctor();
let _o = async || f();
Expand Down
19 changes: 14 additions & 5 deletions tests/ui/async_yields_async.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ error: an async construct yields a type which is itself awaitable
LL | let _h = async {
| _____________________-
LL | |/ async {
LL | ||
LL | ||
LL | || 3
LL | || }
| ||_________^ awaitable value not awaited
Expand All @@ -14,12 +16,14 @@ LL | | };
help: consider awaiting this value
|
LL ~ async {
LL +
LL +
LL + 3
LL + }.await
|

error: an async construct yields a type which is itself awaitable
--> $DIR/async_yields_async.rs:44:9
--> $DIR/async_yields_async.rs:46:9
|
LL | let _i = async {
| ____________________-
Expand All @@ -28,15 +32,17 @@ LL | | CustomFutureType
| | |
| | awaitable value not awaited
| | help: consider awaiting this value: `CustomFutureType.await`
LL | |
LL | | };
| |_____- outer async construct

error: an async construct yields a type which is itself awaitable
--> $DIR/async_yields_async.rs:50:9
--> $DIR/async_yields_async.rs:53:9
|
LL | let _j = async || {
| ________________________-
LL | |/ async {
LL | ||
LL | || 3
LL | || }
| ||_________^ awaitable value not awaited
Expand All @@ -46,12 +52,13 @@ LL | | };
help: consider awaiting this value
|
LL ~ async {
LL +
LL + 3
LL + }.await
|

error: an async construct yields a type which is itself awaitable
--> $DIR/async_yields_async.rs:55:9
--> $DIR/async_yields_async.rs:59:9
|
LL | let _k = async || {
| _______________________-
Expand All @@ -60,11 +67,12 @@ LL | | CustomFutureType
| | |
| | awaitable value not awaited
| | help: consider awaiting this value: `CustomFutureType.await`
LL | |
LL | | };
| |_____- outer async construct

error: an async construct yields a type which is itself awaitable
--> $DIR/async_yields_async.rs:57:23
--> $DIR/async_yields_async.rs:62:23
|
LL | let _l = async || CustomFutureType;
| ^^^^^^^^^^^^^^^^
Expand All @@ -74,7 +82,7 @@ LL | let _l = async || CustomFutureType;
| help: consider awaiting this value: `CustomFutureType.await`

error: an async construct yields a type which is itself awaitable
--> $DIR/async_yields_async.rs:63:9
--> $DIR/async_yields_async.rs:69:9
|
LL | let _m = async || {
| _______________________-
Expand All @@ -87,6 +95,7 @@ LL | | CustomFutureType
| | |
| | awaitable value not awaited
| | help: consider awaiting this value: `CustomFutureType.await`
LL | |
LL | | };
| |_____- outer async construct

Expand Down
3 changes: 3 additions & 0 deletions tests/ui/bind_instead_of_map.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ pub fn main() {
let x = Some(5);
// the easiest cases
let _ = x;
//~^ ERROR: using `Option.and_then(Some)`, which is a no-op
let _ = x.map(|o| o + 1);
//~^ ERROR: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed a
// and an easy counter-example
let _ = x.and_then(|o| if o < 32 { Some(o) } else { None });

// Different type
let x: Result<u32, &str> = Ok(1);
let _ = x;
//~^ ERROR: using `Result.and_then(Ok)`, which is a no-op
}

pub fn foo() -> Option<String> {
Expand Down
3 changes: 3 additions & 0 deletions tests/ui/bind_instead_of_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ pub fn main() {
let x = Some(5);
// the easiest cases
let _ = x.and_then(Some);
//~^ ERROR: using `Option.and_then(Some)`, which is a no-op
let _ = x.and_then(|o| Some(o + 1));
//~^ ERROR: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed a
// and an easy counter-example
let _ = x.and_then(|o| if o < 32 { Some(o) } else { None });

// Different type
let x: Result<u32, &str> = Ok(1);
let _ = x.and_then(Ok);
//~^ ERROR: using `Result.and_then(Ok)`, which is a no-op
}

pub fn foo() -> Option<String> {
Expand Down
Loading

0 comments on commit 42424fc

Please sign in to comment.