Skip to content

Commit 371de04

Browse files
committed
add ui tests for E0373 suggestion
1 parent 5d7eda2 commit 371de04

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ run-rustfix
2+
3+
// check to make sure that we suggest adding `move` after `static`
4+
5+
#![feature(coroutines)]
6+
7+
fn check() -> impl Sized {
8+
let x = 0;
9+
#[coroutine]
10+
static move || {
11+
//~^ ERROR E0373
12+
yield;
13+
x
14+
}
15+
}
16+
17+
fn main() {
18+
check();
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ run-rustfix
2+
3+
// check to make sure that we suggest adding `move` after `static`
4+
5+
#![feature(coroutines)]
6+
7+
fn check() -> impl Sized {
8+
let x = 0;
9+
#[coroutine]
10+
static || {
11+
//~^ ERROR E0373
12+
yield;
13+
x
14+
}
15+
}
16+
17+
fn main() {
18+
check();
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error[E0373]: coroutine may outlive the current function, but it borrows `x`, which is owned by the current function
2+
--> $DIR/static-move-suggestion.rs:10:5
3+
|
4+
LL | static || {
5+
| ^^^^^^^^^ may outlive borrowed value `x`
6+
...
7+
LL | x
8+
| - `x` is borrowed here
9+
|
10+
note: coroutine is returned here
11+
--> $DIR/static-move-suggestion.rs:10:5
12+
|
13+
LL | / static || {
14+
LL | |
15+
LL | | yield;
16+
LL | | x
17+
LL | | }
18+
| |_____^
19+
help: to force the coroutine to take ownership of `x` (and any other referenced variables), use the `move` keyword
20+
|
21+
LL | static move || {
22+
| ++++
23+
24+
error: aborting due to 1 previous error
25+
26+
For more information about this error, try `rustc --explain E0373`.

0 commit comments

Comments
 (0)