Skip to content

Commit 199f961

Browse files
committed
Revise the tests for coroutine/auto-trait-regions
1 parent 96b5ee8 commit 199f961

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

tests/ui/coroutine/auto-trait-regions.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ impl<'a> Foo for &'a OnlyFooIfRef {}
2020

2121
fn assert_foo<T: Foo>(f: T) {}
2222

23+
fn other_assertion() {
24+
// Disallow impls which relates lifetimes in the coroutine interior
25+
let gen = #[coroutine] move || {
26+
let a = A(&mut true, &mut true, No);
27+
//~^ ERROR borrow may still be in use when coroutine yields
28+
//~| ERROR borrow may still be in use when coroutine yields
29+
yield;
30+
assert_foo(a);
31+
};
32+
assert_foo(gen);
33+
//~^ ERROR not general enough
34+
}
35+
2336
fn main() {
2437
// Make sure 'static is erased for coroutine interiors so we can't match it in trait selection
2538
let x: &'static _ = &OnlyFooIfStaticRef(No);
@@ -39,15 +52,4 @@ fn main() {
3952
assert_foo(x);
4053
};
4154
assert_foo(gen); // ok
42-
43-
// Disallow impls which relates lifetimes in the coroutine interior
44-
let gen = #[coroutine] move || {
45-
let a = A(&mut true, &mut true, No);
46-
//~^ ERROR borrow may still be in use when coroutine yields
47-
//~| ERROR borrow may still be in use when coroutine yields
48-
yield;
49-
assert_foo(a);
50-
};
51-
assert_foo(gen);
52-
//~^ ERROR not general enough
5355
}

tests/ui/coroutine/auto-trait-regions.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0626]: borrow may still be in use when coroutine yields
2-
--> $DIR/auto-trait-regions.rs:45:19
2+
--> $DIR/auto-trait-regions.rs:26:19
33
|
44
LL | let gen = #[coroutine] move || {
55
| ------- within this coroutine
@@ -15,7 +15,7 @@ LL | let gen = #[coroutine] static move || {
1515
| ++++++
1616

1717
error[E0626]: borrow may still be in use when coroutine yields
18-
--> $DIR/auto-trait-regions.rs:45:30
18+
--> $DIR/auto-trait-regions.rs:26:30
1919
|
2020
LL | let gen = #[coroutine] move || {
2121
| ------- within this coroutine
@@ -31,22 +31,22 @@ LL | let gen = #[coroutine] static move || {
3131
| ++++++
3232

3333
error: implementation of `Foo` is not general enough
34-
--> $DIR/auto-trait-regions.rs:31:5
34+
--> $DIR/auto-trait-regions.rs:32:5
3535
|
3636
LL | assert_foo(gen);
3737
| ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
3838
|
39-
= note: `&'0 OnlyFooIfStaticRef` must implement `Foo`, for any lifetime `'0`...
40-
= note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef`
39+
= note: `Foo` would have to be implemented for the type `A<'0, '1>`, for any two lifetimes `'0` and `'1`...
40+
= note: ...but `Foo` is actually implemented for the type `A<'_, '2>`, for some specific lifetime `'2`
4141

4242
error: implementation of `Foo` is not general enough
43-
--> $DIR/auto-trait-regions.rs:51:5
43+
--> $DIR/auto-trait-regions.rs:44:5
4444
|
4545
LL | assert_foo(gen);
4646
| ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
4747
|
48-
= note: `Foo` would have to be implemented for the type `A<'0, '1>`, for any two lifetimes `'0` and `'1`...
49-
= note: ...but `Foo` is actually implemented for the type `A<'_, '2>`, for some specific lifetime `'2`
48+
= note: `&'0 OnlyFooIfStaticRef` must implement `Foo`, for any lifetime `'0`...
49+
= note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef`
5050

5151
error: aborting due to 4 previous errors
5252

0 commit comments

Comments
 (0)