From ec64bbbe07df8e502b64e449be86c1613717c0c7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 3 Jan 2020 17:42:44 +0100 Subject: [PATCH 1/3] Small error explanations cleanup --- src/librustc_error_codes/error_codes/E0136.md | 7 +++++-- src/librustc_error_codes/error_codes/E0161.md | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0136.md b/src/librustc_error_codes/error_codes/E0136.md index c0e8c7e061cf5..b91b52c074cd2 100644 --- a/src/librustc_error_codes/error_codes/E0136.md +++ b/src/librustc_error_codes/error_codes/E0136.md @@ -1,5 +1,4 @@ -A binary can only have one entry point, and by default that entry point is the -function `main()`. If there are multiple such functions, please rename one. +More than one `main` function was found. Erroneous code example: @@ -14,3 +13,7 @@ fn main() { // error! // ... } ``` + +A binary can only have one entry point, and by default that entry point is the +`main()` function. If there are multiple instances of this function, please +rename one of them. diff --git a/src/librustc_error_codes/error_codes/E0161.md b/src/librustc_error_codes/error_codes/E0161.md index 26269db2327ce..c2e2f0240f483 100644 --- a/src/librustc_error_codes/error_codes/E0161.md +++ b/src/librustc_error_codes/error_codes/E0161.md @@ -1,5 +1,4 @@ -A value was moved. However, its size was not known at compile time, and only -values of a known size can be moved. +A value was moved whose size was not known at compile time. Erroneous code example: From aab4276477e84545641b1cf69b43612efa6bf702 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 3 Jan 2020 17:42:56 +0100 Subject: [PATCH 2/3] Clean up E0164 explanation --- src/librustc_error_codes/error_codes/E0164.md | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0164.md b/src/librustc_error_codes/error_codes/E0164.md index b41ce6fad8e57..8eb5ace4fe4d4 100644 --- a/src/librustc_error_codes/error_codes/E0164.md +++ b/src/librustc_error_codes/error_codes/E0164.md @@ -1,24 +1,44 @@ -This error means that an attempt was made to match a struct type enum -variant as a non-struct type: +Something which is neither a tuple struct nor a tuple variant was used as a +pattern. + +Erroneous code example: ```compile_fail,E0164 -enum Foo { B { i: u32 } } +enum A { + B, + C, +} + +impl A { + fn new() {} +} -fn bar(foo: Foo) -> u32 { +fn bar(foo: A) { match foo { - Foo::B(i) => i, // error E0164 + A::new() => (), // error! + _ => {} } } ``` -Try using `{}` instead: +This error means that an attempt was made to match something which is neither a +tuple struct nor a tuple variant. Only these two elements are allowed as +pattern: ``` -enum Foo { B { i: u32 } } +enum A { + B, + C, +} + +impl A { + fn new() {} +} -fn bar(foo: Foo) -> u32 { +fn bar(foo: A) { match foo { - Foo::B{i} => i, + A::B => (), // ok! + _ => {} } } ``` From 062cd789588dfc493ef8c69378379024d3670f75 Mon Sep 17 00:00:00 2001 From: Dylan DPC Date: Sat, 4 Jan 2020 11:41:35 +0530 Subject: [PATCH 3/3] Update E0164.md --- src/librustc_error_codes/error_codes/E0164.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_error_codes/error_codes/E0164.md b/src/librustc_error_codes/error_codes/E0164.md index 8eb5ace4fe4d4..48bb6f4b38283 100644 --- a/src/librustc_error_codes/error_codes/E0164.md +++ b/src/librustc_error_codes/error_codes/E0164.md @@ -22,7 +22,7 @@ fn bar(foo: A) { ``` This error means that an attempt was made to match something which is neither a -tuple struct nor a tuple variant. Only these two elements are allowed as +tuple struct nor a tuple variant. Only these two elements are allowed as a pattern: ```