Skip to content

Commit ad7b52c

Browse files
committed
Revise the tests for coroutine/auto-trait-regions
1 parent 91d8bcd commit ad7b52c

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 temporary value dropped while borrowed
28+
//~| ERROR temporary value dropped while borrowed
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 temporary value dropped while borrowed
47-
//~| ERROR temporary value dropped while borrowed
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[E0716]: temporary value dropped while borrowed
2-
--> $DIR/auto-trait-regions.rs:45:24
2+
--> $DIR/auto-trait-regions.rs:26:24
33
|
44
LL | let a = A(&mut true, &mut true, No);
55
| ^^^^ - temporary value is freed at the end of this statement
@@ -16,7 +16,7 @@ LL ~ let a = A(&mut binding, &mut true, No);
1616
|
1717

1818
error[E0716]: temporary value dropped while borrowed
19-
--> $DIR/auto-trait-regions.rs:45:35
19+
--> $DIR/auto-trait-regions.rs:26:35
2020
|
2121
LL | let a = A(&mut true, &mut true, No);
2222
| ^^^^ - temporary value is freed at the end of this statement
@@ -33,22 +33,22 @@ LL ~ let a = A(&mut true, &mut binding, No);
3333
|
3434

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

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

5353
error: aborting due to 4 previous errors
5454

0 commit comments

Comments
 (0)