Skip to content

Commit 587d03b

Browse files
committed
Yield is an expression form, not a statement.
1 parent 1485c16 commit 587d03b

File tree

11 files changed

+16
-12
lines changed

11 files changed

+16
-12
lines changed

src/librustc_mir/borrow_check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
14241424
}
14251425

14261426
/// Reports an error if this is a borrow of local data.
1427-
/// This is called for all Yield statements on movable generators
1427+
/// This is called for all Yield expressions on movable generators
14281428
fn check_for_local_borrow(&mut self, borrow: &BorrowData<'tcx>, yield_span: Span) {
14291429
debug!("check_for_local_borrow({:?})", borrow);
14301430

src/librustc_mir/borrow_check/path_utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ pub(super) fn is_active<'tcx>(
131131
}
132132

133133
/// Determines if a given borrow is borrowing local data
134-
/// This is called for all Yield statements on movable generators
134+
/// This is called for all Yield expressions on movable generators
135135
pub(super) fn borrow_of_local_data(place: &Place<'_>) -> bool {
136136
match place.base {
137137
PlaceBase::Static(_) => false,

src/librustc_typeck/check/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1775,7 +1775,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17751775
self.tcx.sess,
17761776
expr.span,
17771777
E0627,
1778-
"yield statement outside of generator literal"
1778+
"yield expression outside of generator literal"
17791779
)
17801780
.emit();
17811781
}

src/test/ui/feature-gates/feature-gate-generators.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
fn main() {
22
yield true; //~ ERROR yield syntax is experimental
3-
//~^ ERROR yield statement outside of generator literal
3+
//~^ ERROR yield expression outside of generator literal
44
}
55

66
#[cfg(FALSE)]

src/test/ui/feature-gates/feature-gate-generators.stderr

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ LL | yield 0;
2525
= note: for more information, see https://github.com/rust-lang/rust/issues/43122
2626
= help: add `#![feature(generators)]` to the crate attributes to enable
2727

28-
error[E0627]: yield statement outside of generator literal
28+
error[E0627]: yield expression outside of generator literal
2929
--> $DIR/feature-gate-generators.rs:2:5
3030
|
3131
LL | yield true;
3232
| ^^^^^^^^^^
3333

3434
error: aborting due to 4 previous errors
3535

36-
For more information about this error, try `rustc --explain E0658`.
36+
Some errors have detailed explanations: E0627, E0658.
37+
For more information about an error, try `rustc --explain E0627`.
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![feature(generators)]
22

33
const A: u8 = { yield 3u8; 3u8};
4-
//~^ ERROR yield statement outside
4+
//~^ ERROR yield expression outside
55

66
fn main() {}
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
error[E0627]: yield statement outside of generator literal
1+
error[E0627]: yield expression outside of generator literal
22
--> $DIR/yield-in-const.rs:3:17
33
|
44
LL | const A: u8 = { yield 3u8; 3u8};
55
| ^^^^^^^^^
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0627`.
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#![feature(generators)]
22

33
fn main() { yield; }
4-
//~^ ERROR yield statement outside
4+
//~^ ERROR yield expression outside
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
error[E0627]: yield statement outside of generator literal
1+
error[E0627]: yield expression outside of generator literal
22
--> $DIR/yield-in-function.rs:3:13
33
|
44
LL | fn main() { yield; }
55
| ^^^^^
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0627`.
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![feature(generators)]
22

33
static B: u8 = { yield 3u8; 3u8};
4-
//~^ ERROR yield statement outside
4+
//~^ ERROR yield expression outside
55

66
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
error[E0627]: yield statement outside of generator literal
1+
error[E0627]: yield expression outside of generator literal
22
--> $DIR/yield-in-static.rs:3:18
33
|
44
LL | static B: u8 = { yield 3u8; 3u8};
55
| ^^^^^^^^^
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0627`.

0 commit comments

Comments
 (0)