File tree 2 files changed +31
-1
lines changed
2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -346,6 +346,7 @@ E0622: include_str!("./error_codes/E0622.md"),
346
346
E0623 : include_str!( "./error_codes/E0623.md" ) ,
347
347
E0624 : include_str!( "./error_codes/E0624.md" ) ,
348
348
E0626 : include_str!( "./error_codes/E0626.md" ) ,
349
+ E0627 : include_str!( "./error_codes/E0627.md" ) ,
349
350
E0631 : include_str!( "./error_codes/E0631.md" ) ,
350
351
E0633 : include_str!( "./error_codes/E0633.md" ) ,
351
352
E0635 : include_str!( "./error_codes/E0635.md" ) ,
@@ -574,7 +575,6 @@ E0745: include_str!("./error_codes/E0745.md"),
574
575
// E0612, // merged into E0609
575
576
// E0613, // Removed (merged with E0609)
576
577
E0625 , // thread-local statics cannot be accessed at compile-time
577
- E0627 , // yield statement outside of generator literal
578
578
E0628 , // generators cannot have explicit parameters
579
579
E0629 , // missing 'feature' (rustc_const_unstable)
580
580
// rustc_const_unstable attribute must be paired with stable/unstable
Original file line number Diff line number Diff line change
1
+ A yield expression was used outside of the generator literal.
2
+
3
+ Erroneous code example:
4
+
5
+ ``` compile_fail,E0627
6
+ #![feature(generators, generator_trait)]
7
+
8
+ fn fake_generator() -> &'static str {
9
+ yield 1;
10
+ return "foo"
11
+ }
12
+
13
+ fn main() {
14
+ let mut generator = fake_generator;
15
+ }
16
+ ```
17
+
18
+ The error occurs because keyword ` yield ` can only be used inside the generator
19
+ literal. This can be fixed by constructing the generator correctly.
20
+
21
+ ```
22
+ #![feature(generators, generator_trait)]
23
+
24
+ fn main() {
25
+ let mut generator = || {
26
+ yield 1;
27
+ return "foo"
28
+ };
29
+ }
30
+ ```
You can’t perform that action at this time.
0 commit comments