diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2016-05-27 10:50:03 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2016-05-27 10:50:03 +0200 |
| commit | 4ffebe72bf8fc25813aa26aeec5cff82d843ad92 (patch) | |
| tree | 74a3f39dd2b12cdc6440b123078bfe9136f6cb9d /src | |
| parent | caa732a725af1e0f0169c69bfd491a951b984ccf (diff) | |
| parent | dfa0d2c46e4448fe117d26a9c7fff2b68a2f304f (diff) | |
| download | rust-4ffebe72bf8fc25813aa26aeec5cff82d843ad92.tar.gz rust-4ffebe72bf8fc25813aa26aeec5cff82d843ad92.zip | |
Rollup merge of #33865 - GuillaumeGomez:E0084, r=jonathandturner
Improve E0084 error explanation r? @Manishearth cc @steveklabnik
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_typeck/diagnostics.rs | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 40b9b0e01ab..b94c9c4ad19 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -1193,12 +1193,32 @@ discriminant values so that they fit within the existing type. "##, E0084: r##" +An unsupported representation was attempted on a zero-variant enum. + +Erroneous code example: + +```compile_fail +#[repr(i32)] +enum NightWatch {} // error: unsupported representation for zero-variant enum +``` + It is impossible to define an integer type to be used to represent zero-variant enum values because there are no zero-variant enum values. There is no way to -construct an instance of the following type using only safe code: +construct an instance of the following type using only safe code. So you have +two solutions. Either you add variants in your enum: + +``` +#[repr(i32)] +enum NightWatch { + JohnSnow, + Commander, +} +``` + +or you remove the integer represention of your enum: ``` -enum Empty {} +enum NightWatch {} ``` "##, |
