From 4ee18c94d4969a49b81b726260a093f3fd201070 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 22 Dec 2019 20:39:17 +0100 Subject: Clean up E0124 explanation --- src/librustc_error_codes/error_codes/E0124.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/librustc_error_codes/error_codes') diff --git a/src/librustc_error_codes/error_codes/E0124.md b/src/librustc_error_codes/error_codes/E0124.md index a7836526a7d..f08f7e98005 100644 --- a/src/librustc_error_codes/error_codes/E0124.md +++ b/src/librustc_error_codes/error_codes/E0124.md @@ -1,5 +1,6 @@ -You declared two fields of a struct with the same name. Erroneous code -example: +A struct with two fields having the same name has been declared. + +Erroneous code example: ```compile_fail,E0124 struct Foo { -- cgit 1.4.1-3-g733a5 From 1474d2a41a32f7f969c7d924ea917a1390ebe1c6 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 22 Dec 2019 20:39:25 +0100 Subject: Clean up E0128 explanation --- src/librustc_error_codes/error_codes/E0128.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/librustc_error_codes/error_codes') diff --git a/src/librustc_error_codes/error_codes/E0128.md b/src/librustc_error_codes/error_codes/E0128.md index d0a4b32f968..6f8dfe3a73b 100644 --- a/src/librustc_error_codes/error_codes/E0128.md +++ b/src/librustc_error_codes/error_codes/E0128.md @@ -1,4 +1,5 @@ -Type parameter defaults can only use parameters that occur before them. +A type parameter with default value is using forward declared identifier. + Erroneous code example: ```compile_fail,E0128 @@ -7,11 +8,11 @@ struct Foo { field2: U, } // error: type parameters with a default cannot use forward declared -// identifiers +// identifiers ``` -Since type parameters are evaluated in-order, you may be able to fix this issue -by doing: +Type parameter defaults can only use parameters that occur before them. Since +type parameters are evaluated in-order, this issue could be fixed by doing: ``` struct Foo { -- cgit 1.4.1-3-g733a5 From 256eec4ae0653e35cdd39261a2b59d69c91b1a71 Mon Sep 17 00:00:00 2001 From: Dylan DPC Date: Mon, 23 Dec 2019 12:55:33 +0530 Subject: Update E0124.md --- src/librustc_error_codes/error_codes/E0124.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/librustc_error_codes/error_codes') diff --git a/src/librustc_error_codes/error_codes/E0124.md b/src/librustc_error_codes/error_codes/E0124.md index f08f7e98005..8af7cb819cf 100644 --- a/src/librustc_error_codes/error_codes/E0124.md +++ b/src/librustc_error_codes/error_codes/E0124.md @@ -1,4 +1,4 @@ -A struct with two fields having the same name has been declared. +A struct was declared with two fields having the same name. Erroneous code example: -- cgit 1.4.1-3-g733a5 From 1485c168990b2dbb6e2858bc09af0254c1af9491 Mon Sep 17 00:00:00 2001 From: Donough Liu Date: Mon, 23 Dec 2019 21:05:02 +0800 Subject: Add long error code explanation message for E0627 --- src/librustc_error_codes/error_codes.rs | 2 +- src/librustc_error_codes/error_codes/E0627.md | 30 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/librustc_error_codes/error_codes/E0627.md (limited to 'src/librustc_error_codes/error_codes') 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" + }; +} +``` -- cgit 1.4.1-3-g733a5