-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Error if enum variant don't have a field
- Loading branch information
Showing
3 changed files
with
83 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// TODO: Make `register()` is usable for trait definition. | ||
mod private_for_thin_delegate { | ||
#[thin_delegate::register(AsRef)] | ||
pub trait AsRef<T: ?Sized> { | ||
/// Converts this type into a shared reference of the (usually inferred) input type. | ||
fn as_ref(&self) -> &T; | ||
} | ||
} | ||
|
||
#[thin_delegate::derive_delegate(AsRef<str>)] | ||
enum Named { | ||
Named { | ||
x: String, | ||
y: String, | ||
}, | ||
} | ||
|
||
#[thin_delegate::derive_delegate(AsRef<str>)] | ||
enum Unnamed { | ||
Unnamed(String, String), | ||
} | ||
|
||
#[thin_delegate::derive_delegate(AsRef<str>)] | ||
enum Unit { | ||
Unit, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
error: fields of enum variant must be a field | ||
--> tests/ui/fail_fields_of_enum_must_be_a_field.rs:12:11 | ||
| | ||
12 | Named { | ||
| ___________^ | ||
13 | | x: String, | ||
14 | | y: String, | ||
15 | | }, | ||
| |_____^ | ||
|
||
error: fields of enum variant must be a field | ||
--> tests/ui/fail_fields_of_enum_must_be_a_field.rs:20:12 | ||
| | ||
20 | Unnamed(String, String), | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: fields of enum variant must be a field | ||
--> tests/ui/fail_fields_of_enum_must_be_a_field.rs:25:5 | ||
| | ||
25 | Unit, | ||
| ^^^^ |