Skip to content

Commit 85243d3

Browse files
committed
Fix CI test failure due to diagnostic-width
Where the error relevant for these tests is emitted in `report_selection_error` in `fulfillment_errors.rs`, there's a check for the diagostic width. If the explanation is too wide for that width, it's moved to the `help` instead. This was causing the results from CI to not match the results observed in blessing the test locally. Let's update the relevant tests to fix this width and to test it both in a `narrow` and in a `wide` configuration. Thanks to jieyouxu for figuring this out.
1 parent 51d09de commit 85243d3

6 files changed

+120
-30
lines changed

tests/ui/iterators/iter-macro-not-async-closure-simplified.stderr renamed to tests/ui/iterators/iter-macro-not-async-closure-simplified.narrow.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:12:21: 12:28}: AsyncFnOnce()` is not satisfied
2-
--> $DIR/iter-macro-not-async-closure-simplified.rs:18:21
1+
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:21:21: 21:28}: AsyncFnOnce()` is not satisfied
2+
--> $DIR/iter-macro-not-async-closure-simplified.rs:27:21
33
|
44
LL | call_async_once(f);
55
| --------------- ^ unsatisfied trait bound
66
| |
77
| required by a bound introduced by this call
88
|
9-
= help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:12:21: 12:28}`
9+
= help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:21:21: 21:28}`
1010
note: required by a bound in `call_async_once`
11-
--> $DIR/iter-macro-not-async-closure-simplified.rs:8:28
11+
--> $DIR/iter-macro-not-async-closure-simplified.rs:18:28
1212
|
13-
LL | fn call_async_once(_: impl AsyncFnOnce()) {
14-
| ^^^^^^^^^^^^^ required by this bound in `call_async_once`
13+
LL | ...pl AsyncFnOnce()) {}
14+
| ^^^^^^^^^^^^^ required by this bound in `call_async_once`
1515

1616
error: aborting due to 1 previous error
1717

tests/ui/iterators/iter-macro-not-async-closure-simplified.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1-
// This test ensures iterators created with the `iter!` macro are not accidentally async closures.
1+
// This test ensures iterators created with the `iter!` macro are not
2+
// accidentally async closures.
3+
//
4+
// We test this both in a `narrow` and `wide` configuration because
5+
// the way that the diagnostic is emitted varies depending on the
6+
// diagnostic width. If it's too narrow to fit the explanation, that
7+
// explanation is moved to the `help` instead of the span label.
8+
//
29
//@ edition: 2024
10+
//@ revisions: narrow wide
11+
//@[narrow] compile-flags: --diagnostic-width=20
12+
//@[wide] compile-flags: --diagnostic-width=300
313

414
#![feature(yield_expr, iter_macro)]
515

616
use std::iter::iter;
717

8-
fn call_async_once(_: impl AsyncFnOnce()) {
9-
}
18+
fn call_async_once(_: impl AsyncFnOnce()) {}
1019

1120
fn main() {
1221
let f = iter! { move || {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:21:21: 21:28}: AsyncFnOnce()` is not satisfied
2+
--> $DIR/iter-macro-not-async-closure-simplified.rs:27:21
3+
|
4+
LL | call_async_once(f);
5+
| --------------- ^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:21:21: 21:28}`
6+
| |
7+
| required by a bound introduced by this call
8+
|
9+
note: required by a bound in `call_async_once`
10+
--> $DIR/iter-macro-not-async-closure-simplified.rs:18:28
11+
|
12+
LL | fn call_async_once(_: impl AsyncFnOnce()) {}
13+
| ^^^^^^^^^^^^^ required by this bound in `call_async_once`
14+
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}: AsyncFnOnce()` is not satisfied
2+
--> $DIR/iter-macro-not-async-closure.rs:32:34
3+
|
4+
LL | ...n!(call_async_once(f));
5+
| --------------- ^ unsatisfied trait bound
6+
| |
7+
| required by a bound introduced by this call
8+
|
9+
= help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}`
10+
note: required by a bound in `call_async_once`
11+
--> $DIR/iter-macro-not-async-closure.rs:21:34
12+
|
13+
LL | ...pl AsyncFnOnce()) {
14+
| ^^^^^^^^^^^^^ required by this bound in `call_async_once`
15+
16+
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}: AsyncFnOnce()` is not satisfied
17+
--> $DIR/iter-macro-not-async-closure.rs:32:18
18+
|
19+
LL | ...n!(call_async_once(f));
20+
| ^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
21+
|
22+
= help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}`
23+
note: required by a bound in `call_async_once`
24+
--> $DIR/iter-macro-not-async-closure.rs:21:34
25+
|
26+
LL | ...pl AsyncFnOnce()) {
27+
| ^^^^^^^^^^^^^ required by this bound in `call_async_once`
28+
29+
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}: AsyncFnOnce()` is not satisfied
30+
--> $DIR/iter-macro-not-async-closure.rs:32:13
31+
|
32+
LL | ... = pin!(call_async_once(f));
33+
| ^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
34+
|
35+
= help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}`
36+
note: required by a bound in `call_async_once`
37+
--> $DIR/iter-macro-not-async-closure.rs:21:34
38+
|
39+
LL | ...pl AsyncFnOnce()) {
40+
| ^^^^^^^^^^^^^ required by this bound in `call_async_once`
41+
= note: this error originates in the macro `pin` (in Nightly builds, run with -Z macro-backtrace for more info)
42+
43+
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}: AsyncFnOnce()` is not satisfied
44+
--> $DIR/iter-macro-not-async-closure.rs:36:5
45+
|
46+
LL | ...::noop()));
47+
| ...^^^^^^^^^^ unsatisfied trait bound
48+
|
49+
= help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}`
50+
note: required by a bound in `call_async_once`
51+
--> $DIR/iter-macro-not-async-closure.rs:21:34
52+
|
53+
LL | ...pl AsyncFnOnce()) {
54+
| ^^^^^^^^^^^^^ required by this bound in `call_async_once`
55+
56+
error: aborting due to 4 previous errors
57+
58+
For more information about this error, try `rustc --explain E0277`.

tests/ui/iterators/iter-macro-not-async-closure.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
// This test ensures iterators created with the `iter!` macro are not accidentally async closures.
1+
// This test ensures iterators created with the `iter!` macro are not
2+
// accidentally async closures.
3+
//
4+
// We test this both in a `narrow` and `wide` configuration because
5+
// the way that the diagnostic is emitted varies depending on the
6+
// diagnostic width. If it's too narrow to fit the explanation, that
7+
// explanation is moved to the `help` instead of the span label.
8+
//
29
//@ edition: 2024
10+
//@ revisions: narrow wide
11+
//@[narrow] compile-flags: --diagnostic-width=20
12+
//@[wide] compile-flags: --diagnostic-width=300
313

414
#![feature(yield_expr, iter_macro)]
515

tests/ui/iterators/iter-macro-not-async-closure.stderr renamed to tests/ui/iterators/iter-macro-not-async-closure.wide.stderr

+16-20
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,50 @@
1-
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:16:21: 16:28}: AsyncFnOnce()` is not satisfied
2-
--> $DIR/iter-macro-not-async-closure.rs:22:34
1+
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}: AsyncFnOnce()` is not satisfied
2+
--> $DIR/iter-macro-not-async-closure.rs:32:34
33
|
44
LL | let x = pin!(call_async_once(f));
5-
| --------------- ^ unsatisfied trait bound
5+
| --------------- ^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}`
66
| |
77
| required by a bound introduced by this call
88
|
9-
= help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:16:21: 16:28}`
109
note: required by a bound in `call_async_once`
11-
--> $DIR/iter-macro-not-async-closure.rs:11:34
10+
--> $DIR/iter-macro-not-async-closure.rs:21:34
1211
|
1312
LL | async fn call_async_once(f: impl AsyncFnOnce()) {
1413
| ^^^^^^^^^^^^^ required by this bound in `call_async_once`
1514

16-
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:16:21: 16:28}: AsyncFnOnce()` is not satisfied
17-
--> $DIR/iter-macro-not-async-closure.rs:22:18
15+
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}: AsyncFnOnce()` is not satisfied
16+
--> $DIR/iter-macro-not-async-closure.rs:32:18
1817
|
1918
LL | let x = pin!(call_async_once(f));
20-
| ^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
19+
| ^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}`
2120
|
22-
= help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:16:21: 16:28}`
2321
note: required by a bound in `call_async_once`
24-
--> $DIR/iter-macro-not-async-closure.rs:11:34
22+
--> $DIR/iter-macro-not-async-closure.rs:21:34
2523
|
2624
LL | async fn call_async_once(f: impl AsyncFnOnce()) {
2725
| ^^^^^^^^^^^^^ required by this bound in `call_async_once`
2826

29-
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:16:21: 16:28}: AsyncFnOnce()` is not satisfied
30-
--> $DIR/iter-macro-not-async-closure.rs:22:13
27+
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}: AsyncFnOnce()` is not satisfied
28+
--> $DIR/iter-macro-not-async-closure.rs:32:13
3129
|
3230
LL | let x = pin!(call_async_once(f));
33-
| ^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
31+
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}`
3432
|
35-
= help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:16:21: 16:28}`
3633
note: required by a bound in `call_async_once`
37-
--> $DIR/iter-macro-not-async-closure.rs:11:34
34+
--> $DIR/iter-macro-not-async-closure.rs:21:34
3835
|
3936
LL | async fn call_async_once(f: impl AsyncFnOnce()) {
4037
| ^^^^^^^^^^^^^ required by this bound in `call_async_once`
4138
= note: this error originates in the macro `pin` (in Nightly builds, run with -Z macro-backtrace for more info)
4239

43-
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:16:21: 16:28}: AsyncFnOnce()` is not satisfied
44-
--> $DIR/iter-macro-not-async-closure.rs:26:5
40+
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}: AsyncFnOnce()` is not satisfied
41+
--> $DIR/iter-macro-not-async-closure.rs:36:5
4542
|
4643
LL | x.poll(&mut Context::from_waker(Waker::noop()));
47-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
44+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}`
4845
|
49-
= help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:16:21: 16:28}`
5046
note: required by a bound in `call_async_once`
51-
--> $DIR/iter-macro-not-async-closure.rs:11:34
47+
--> $DIR/iter-macro-not-async-closure.rs:21:34
5248
|
5349
LL | async fn call_async_once(f: impl AsyncFnOnce()) {
5450
| ^^^^^^^^^^^^^ required by this bound in `call_async_once`

0 commit comments

Comments
 (0)