Skip to content

Commit 42424fc

Browse files
Fix missing ui tests annotations
1 parent af2bb8b commit 42424fc

File tree

576 files changed

+7041
-4112
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

576 files changed

+7041
-4112
lines changed

tests/ui/as_underscore.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ fn foo(_n: usize) {}
55
fn main() {
66
let n: u16 = 256;
77
foo(n as _);
8+
//~^ ERROR: using `as _` conversion
9+
//~| NOTE: `-D clippy::as-underscore` implied by `-D warnings`
810

911
let n = 0_u128;
1012
let _n: u8 = n as _;
13+
//~^ ERROR: using `as _` conversion
1114
}

tests/ui/as_underscore.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | foo(n as _);
99
= note: `-D clippy::as-underscore` implied by `-D warnings`
1010

1111
error: using `as _` conversion
12-
--> $DIR/as_underscore.rs:10:18
12+
--> $DIR/as_underscore.rs:12:18
1313
|
1414
LL | let _n: u8 = n as _;
1515
| ^^^^^-

tests/ui/assertions_on_result_states.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ fn main() {
2222
let r: Result<Foo, DebugFoo> = Ok(Foo);
2323
debug_assert!(r.is_ok());
2424
assert!(r.is_ok());
25+
//~^ ERROR: called `assert!` with `Result::is_ok`
26+
//~| NOTE: `-D clippy::assertions-on-result-states` implied by `-D warnings`
2527

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

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

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

6166
// test reference to ok
6267
let r: Result<CopyFoo, CopyFoo> = Ok(CopyFoo);
6368
fn test_ref_copy_ok(r: &Result<CopyFoo, CopyFoo>) {
6469
assert!(r.is_ok());
70+
//~^ ERROR: called `assert!` with `Result::is_ok`
6571
}
6672
test_ref_copy_ok(&r);
6773
r.unwrap();
@@ -70,6 +76,7 @@ fn main() {
7076
let r: Result<DebugFoo, Foo> = Err(Foo);
7177
debug_assert!(r.is_err());
7278
assert!(r.is_err());
79+
//~^ ERROR: called `assert!` with `Result::is_err`
7380

7481
// test err with non-debug value type
7582
let r: Result<Foo, Foo> = Err(Foo);
@@ -80,4 +87,5 @@ fn main() {
8087
fn issue9450() {
8188
let res: Result<i32, i32> = Ok(1);
8289
assert!(res.is_err())
90+
//~^ ERROR: called `assert!` with `Result::is_err`
8391
}

tests/ui/assertions_on_result_states.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,37 @@ LL | assert!(r.is_ok());
77
= note: `-D clippy::assertions-on-result-states` implied by `-D warnings`
88

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

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

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

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

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

3939
error: called `assert!` with `Result::is_err`
40-
--> $DIR/assertions_on_result_states.rs:82:5
40+
--> $DIR/assertions_on_result_states.rs:89:5
4141
|
4242
LL | assert!(res.is_err())
4343
| ^^^^^^^^^^^^^^^^^^^^^ help: replace with: `res.unwrap_err();`

tests/ui/assign_ops.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,37 @@ use core::num::Wrapping;
55
fn main() {
66
let mut a = 5;
77
a = a + 1;
8+
//~^ ERROR: manual implementation of an assign operation
9+
//~| NOTE: `-D clippy::assign-op-pattern` implied by `-D warnings`
810
a = 1 + a;
11+
//~^ ERROR: manual implementation of an assign operation
912
a = a - 1;
13+
//~^ ERROR: manual implementation of an assign operation
1014
a = a * 99;
15+
//~^ ERROR: manual implementation of an assign operation
1116
a = 42 * a;
17+
//~^ ERROR: manual implementation of an assign operation
1218
a = a / 2;
19+
//~^ ERROR: manual implementation of an assign operation
1320
a = a % 5;
21+
//~^ ERROR: manual implementation of an assign operation
1422
a = a & 1;
23+
//~^ ERROR: manual implementation of an assign operation
1524
a = 1 - a;
1625
a = 5 / a;
1726
a = 42 % a;
1827
a = 6 << a;
1928
let mut s = String::new();
2029
s = s + "bla";
30+
//~^ ERROR: manual implementation of an assign operation
2131

2232
// Issue #9180
2333
let mut a = Wrapping(0u32);
2434
a = a + Wrapping(1u32);
35+
//~^ ERROR: manual implementation of an assign operation
2536
let mut v = vec![0u32, 1u32];
2637
v[0] = v[0] + v[1];
38+
//~^ ERROR: manual implementation of an assign operation
2739
let mut v = vec![Wrapping(0u32), Wrapping(1u32)];
2840
v[0] = v[0] + v[1];
2941
let _ = || v[0] = v[0] + v[1];

tests/ui/assign_ops.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,61 +7,61 @@ LL | a = a + 1;
77
= note: `-D clippy::assign-op-pattern` implied by `-D warnings`
88

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

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

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

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

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

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

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

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

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

6363
error: manual implementation of an assign operation
64-
--> $DIR/assign_ops.rs:26:5
64+
--> $DIR/assign_ops.rs:37:5
6565
|
6666
LL | v[0] = v[0] + v[1];
6767
| ^^^^^^^^^^^^^^^^^^ help: replace it with: `v[0] += v[1]`

tests/ui/async_yields_async.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,37 @@ fn main() {
3737
};
3838
let _h = async {
3939
async {
40+
//~^ ERROR: an async construct yields a type which is itself awaitable
41+
//~| NOTE: `-D clippy::async-yields-async` implied by `-D warnings`
4042
3
4143
}
4244
};
4345
let _i = async {
4446
CustomFutureType
47+
//~^ ERROR: an async construct yields a type which is itself awaitable
4548
};
4649
let _i = async || {
4750
3
4851
};
4952
let _j = async || {
5053
async {
54+
//~^ ERROR: an async construct yields a type which is itself awaitable
5155
3
5256
}
5357
};
5458
let _k = async || {
5559
CustomFutureType
60+
//~^ ERROR: an async construct yields a type which is itself awaitable
5661
};
5762
let _l = async || CustomFutureType;
63+
//~^ ERROR: an async construct yields a type which is itself awaitable
5864
let _m = async || {
5965
println!("I'm bored");
6066
// Some more stuff
6167

6268
// Finally something to await
6369
CustomFutureType
70+
//~^ ERROR: an async construct yields a type which is itself awaitable
6471
};
6572
let _n = async || custom_future_type_ctor();
6673
let _o = async || f();

tests/ui/async_yields_async.stderr

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ error: an async construct yields a type which is itself awaitable
44
LL | let _h = async {
55
| _____________________-
66
LL | |/ async {
7+
LL | ||
8+
LL | ||
79
LL | || 3
810
LL | || }
911
| ||_________^ awaitable value not awaited
@@ -14,12 +16,14 @@ LL | | };
1416
help: consider awaiting this value
1517
|
1618
LL ~ async {
19+
LL +
20+
LL +
1721
LL + 3
1822
LL + }.await
1923
|
2024

2125
error: an async construct yields a type which is itself awaitable
22-
--> $DIR/async_yields_async.rs:44:9
26+
--> $DIR/async_yields_async.rs:46:9
2327
|
2428
LL | let _i = async {
2529
| ____________________-
@@ -28,15 +32,17 @@ LL | | CustomFutureType
2832
| | |
2933
| | awaitable value not awaited
3034
| | help: consider awaiting this value: `CustomFutureType.await`
35+
LL | |
3136
LL | | };
3237
| |_____- outer async construct
3338

3439
error: an async construct yields a type which is itself awaitable
35-
--> $DIR/async_yields_async.rs:50:9
40+
--> $DIR/async_yields_async.rs:53:9
3641
|
3742
LL | let _j = async || {
3843
| ________________________-
3944
LL | |/ async {
45+
LL | ||
4046
LL | || 3
4147
LL | || }
4248
| ||_________^ awaitable value not awaited
@@ -46,12 +52,13 @@ LL | | };
4652
help: consider awaiting this value
4753
|
4854
LL ~ async {
55+
LL +
4956
LL + 3
5057
LL + }.await
5158
|
5259

5360
error: an async construct yields a type which is itself awaitable
54-
--> $DIR/async_yields_async.rs:55:9
61+
--> $DIR/async_yields_async.rs:59:9
5562
|
5663
LL | let _k = async || {
5764
| _______________________-
@@ -60,11 +67,12 @@ LL | | CustomFutureType
6067
| | |
6168
| | awaitable value not awaited
6269
| | help: consider awaiting this value: `CustomFutureType.await`
70+
LL | |
6371
LL | | };
6472
| |_____- outer async construct
6573

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

7684
error: an async construct yields a type which is itself awaitable
77-
--> $DIR/async_yields_async.rs:63:9
85+
--> $DIR/async_yields_async.rs:69:9
7886
|
7987
LL | let _m = async || {
8088
| _______________________-
@@ -87,6 +95,7 @@ LL | | CustomFutureType
8795
| | |
8896
| | awaitable value not awaited
8997
| | help: consider awaiting this value: `CustomFutureType.await`
98+
LL | |
9099
LL | | };
91100
| |_____- outer async construct
92101

tests/ui/bind_instead_of_map.fixed

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ pub fn main() {
66
let x = Some(5);
77
// the easiest cases
88
let _ = x;
9+
//~^ ERROR: using `Option.and_then(Some)`, which is a no-op
910
let _ = x.map(|o| o + 1);
11+
//~^ ERROR: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed a
1012
// and an easy counter-example
1113
let _ = x.and_then(|o| if o < 32 { Some(o) } else { None });
1214

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

1821
pub fn foo() -> Option<String> {

tests/ui/bind_instead_of_map.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ pub fn main() {
66
let x = Some(5);
77
// the easiest cases
88
let _ = x.and_then(Some);
9+
//~^ ERROR: using `Option.and_then(Some)`, which is a no-op
910
let _ = x.and_then(|o| Some(o + 1));
11+
//~^ ERROR: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed a
1012
// and an easy counter-example
1113
let _ = x.and_then(|o| if o < 32 { Some(o) } else { None });
1214

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

1821
pub fn foo() -> Option<String> {

0 commit comments

Comments
 (0)