diff options
Diffstat (limited to 'compiler/rustc_error_codes/src')
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0665.md | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0665.md b/compiler/rustc_error_codes/src/error_codes/E0665.md index d5fd2130840..caa94423377 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0665.md +++ b/compiler/rustc_error_codes/src/error_codes/E0665.md @@ -1,10 +1,9 @@ -#### Note: this error code is no longer emitted by the compiler. - -The `Default` trait was derived on an enum. +The `Default` trait was derived on an enum without specifying the default +variant. Erroneous code example: -```compile_fail +```compile_fail,E0665 #[derive(Default)] enum Food { Sweet, @@ -16,8 +15,8 @@ The `Default` cannot be derived on an enum for the simple reason that the compiler doesn't know which value to pick by default whereas it can for a struct as long as all its fields implement the `Default` trait as well. -For the case where the desired default variant has no data, you can annotate -it with `#[default]` to derive it: +For the case where the desired default variant has no payload, you can +annotate it with `#[default]` to derive it: ``` #[derive(Default)] @@ -28,8 +27,8 @@ enum Food { } ``` -In the case where the default variant does have data, you will have to -implement `Default` on your enum "by hand": +In the case where the default variant does have a payload, you will have to +implement `Default` on your enum manually: ``` enum Food { |
