summary refs log tree commit diff
path: root/src/librustc_error_codes
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-12-24 04:39:58 +0100
committerGitHub <noreply@github.com>2019-12-24 04:39:58 +0100
commita75968a7829bf140d66f896084c2dfbdcc79cd30 (patch)
tree1f8fb252c00a5df968c21cbbe62a79befdfe11df /src/librustc_error_codes
parentd130e8d550909413299bc9ac11490f98cb55340a (diff)
parent587d03bea89b2b551633aa561073ba97409a5dac (diff)
downloadrust-a75968a7829bf140d66f896084c2dfbdcc79cd30.tar.gz
rust-a75968a7829bf140d66f896084c2dfbdcc79cd30.zip
Rollup merge of #67551 - ldm0:E0627, r=Dylan-DPC
Add long error code explanation message for E0627

Part of #61137.

r? @GuillaumeGomez
Diffstat (limited to 'src/librustc_error_codes')
-rw-r--r--src/librustc_error_codes/error_codes.rs2
-rw-r--r--src/librustc_error_codes/error_codes/E0627.md30
2 files changed, 31 insertions, 1 deletions
diff --git a/src/librustc_error_codes/error_codes.rs b/src/librustc_error_codes/error_codes.rs
index 9c1bec39b29..fbcc976bd49 100644
--- a/src/librustc_error_codes/error_codes.rs
+++ b/src/librustc_error_codes/error_codes.rs
@@ -346,6 +346,7 @@ E0622: include_str!("./error_codes/E0622.md"),
 E0623: include_str!("./error_codes/E0623.md"),
 E0624: include_str!("./error_codes/E0624.md"),
 E0626: include_str!("./error_codes/E0626.md"),
+E0627: include_str!("./error_codes/E0627.md"),
 E0631: include_str!("./error_codes/E0631.md"),
 E0633: include_str!("./error_codes/E0633.md"),
 E0635: include_str!("./error_codes/E0635.md"),
@@ -574,7 +575,6 @@ E0745: include_str!("./error_codes/E0745.md"),
 //  E0612, // merged into E0609
 //  E0613, // Removed (merged with E0609)
     E0625, // thread-local statics cannot be accessed at compile-time
-    E0627, // yield statement outside of generator literal
     E0628, // generators cannot have explicit parameters
     E0629, // missing 'feature' (rustc_const_unstable)
     // rustc_const_unstable attribute must be paired with stable/unstable
diff --git a/src/librustc_error_codes/error_codes/E0627.md b/src/librustc_error_codes/error_codes/E0627.md
new file mode 100644
index 00000000000..21358e1e567
--- /dev/null
+++ b/src/librustc_error_codes/error_codes/E0627.md
@@ -0,0 +1,30 @@
+A yield expression was used outside of the generator literal.
+
+Erroneous code example:
+
+```compile_fail,E0627
+#![feature(generators, generator_trait)]
+
+fn fake_generator() -> &'static str {
+    yield 1;
+    return "foo"
+}
+
+fn main() {
+    let mut generator = fake_generator;
+}
+```
+
+The error occurs because keyword `yield` can only be used inside the generator
+literal. This can be fixed by constructing the generator correctly.
+
+```
+#![feature(generators, generator_trait)]
+
+fn main() {
+    let mut generator = || {
+        yield 1;
+        return "foo"
+    };
+}
+```