rust/tests/target/enum.rs

290 lines
7.2 KiB
Rust
Raw Normal View History

// rustfmt-wrap_comments: true
2015-05-29 10:41:26 +00:00
// Enums test
#[atrr]
pub enum Test {
A,
2015-06-23 13:58:58 +00:00
B(u32, A /* comment */, SomeType),
2015-05-29 10:41:26 +00:00
/// Doc comment
C,
}
pub enum Foo<'a, Y: Baz>
2017-06-12 04:01:41 +00:00
where
X: Whatever,
2015-05-29 10:41:26 +00:00
{
A,
}
enum EmtpyWithComment {
// Some comment
}
// C-style enum
enum Bar {
A = 1,
#[someAttr(test)]
B = 2, // comment
2015-05-29 10:41:26 +00:00
C,
}
enum LongVariants {
2017-06-12 04:01:41 +00:00
First(
LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOONG, // comment
VARIANT,
2017-06-12 04:01:41 +00:00
),
2015-05-29 10:41:26 +00:00
// This is the second variant
Second,
}
2015-06-23 13:58:58 +00:00
enum StructLikeVariants {
Normal(u32, String),
StructLike {
x: i32, // Test comment
// Pre-comment
2018-01-11 07:53:13 +00:00
#[Attr50]
y: SomeType, // Aanother Comment
},
SL {
a: A,
},
2015-06-23 13:58:58 +00:00
}
enum X {
2017-06-12 04:01:41 +00:00
CreateWebGLPaintTask(
Size2D<i32>,
GLContextAttributes,
IpcSender<Result<(IpcSender<CanvasMsg>, usize), String>>,
2017-06-12 04:01:41 +00:00
), // This is a post comment
}
pub enum EnumWithAttributes {
2017-12-17 06:23:17 +00:00
//This is a pre comment
// AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
TupleVar(usize, usize, usize), /* AAAA AAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAA
* AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
// Pre Comment
#[rustfmt::skip]
SkippedItem(String,String,), // Post-comment
#[another_attr]
#[attr2]
ItemStruct {
x: usize,
y: usize,
}, /* Comment AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
// And another
ForcedPreflight, /* AAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
* AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
}
pub enum SingleTuple {
// Pre Comment AAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
// AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Match(usize, usize, String), /* Post-comment AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
}
pub enum SingleStruct {
Match { name: String, loc: usize }, // Post-comment
}
pub enum GenericEnum<I, T>
2017-06-12 04:01:41 +00:00
where
I: Iterator<Item = T>,
{
// Pre Comment
2017-07-05 16:03:20 +00:00
Left { list: I, root: T }, // Post-comment
Right { list: I, root: T }, // Post Comment
}
enum EmtpyWithComment {
// Some comment
}
enum TestFormatFails {
2017-08-11 08:54:20 +00:00
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
}
fn nested_enum_test() {
if true {
enum TestEnum {
2017-06-12 04:01:41 +00:00
One(
usize,
usize,
usize,
usize,
usize,
usize,
usize,
usize,
usize,
usize,
usize,
usize,
usize,
usize,
2017-06-12 04:01:41 +00:00
usize,
usize,
2017-06-12 04:01:41 +00:00
), /* AAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAA
* AAAAAAAAAAAAAAAAAAAAAA */
Two, /* AAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
* AAAAAAAAAAAAAAAAAA */
}
enum TestNestedFormatFail {
2017-08-11 08:54:20 +00:00
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
}
}
}
2015-10-18 22:25:38 +00:00
pub struct EmtpyWithComment {
// FIXME: Implement this struct
}
// #1115
pub enum Bencoding<'i> {
Str(&'i [u8]),
Int(i64),
List(Vec<Bencoding<'i>>),
/// A bencoded dict value. The first element the slice of bytes in the
/// source that the dict is composed of. The second is the dict, decoded
/// into an ordered map.
// TODO make Dict "structlike" AKA name the two values.
Dict(&'i [u8], BTreeMap<&'i [u8], Bencoding<'i>>),
}
// #1261
pub enum CoreResourceMsg {
2017-06-12 04:01:41 +00:00
SetCookieForUrl(
ServoUrl,
2018-03-28 08:41:58 +00:00
#[serde(
deserialize_with = "::hyper_serde::deserialize",
serialize_with = "::hyper_serde::serialize"
)]
2017-06-12 04:01:41 +00:00
Cookie,
CookieSource,
2017-06-12 04:01:41 +00:00
),
}
2017-07-25 09:51:29 +00:00
enum Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
{}
enum Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
{}
enum Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
{}
enum Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
{
Foo,
}
2017-08-11 08:54:20 +00:00
// #1046
pub enum Entry<'a, K: 'a, V: 'a> {
2017-09-19 02:41:50 +00:00
Vacant(#[stable(feature = "rust1", since = "1.0.0")] VacantEntry<'a, K, V>),
Occupied(#[stable(feature = "rust1", since = "1.0.0")] OccupiedEntry<'a, K, V>),
2017-08-11 08:54:20 +00:00
}
// #2081
pub enum ForegroundColor {
CYAN =
(winapi::FOREGROUND_INTENSITY | winapi::FOREGROUND_GREEN | winapi::FOREGROUND_BLUE) as u16,
}
2017-10-30 12:35:23 +00:00
// #2098
pub enum E<'a> {
V(<std::slice::Iter<'a, Xxxxxxxxxxxxxx> as Iterator>::Item),
}
2017-11-16 07:01:50 +00:00
// #1809
enum State {
TryRecv {
pos: usize,
lap: u8,
closed_count: usize,
},
Subscribe {
pos: usize,
},
IsReady {
pos: usize,
ready: bool,
},
Unsubscribe {
pos: usize,
lap: u8,
id_woken: usize,
},
FinalTryRecv {
pos: usize,
id_woken: usize,
},
TimedOut,
Disconnected,
}
2017-11-27 04:49:53 +00:00
// #2190
#[derive(Debug, Fail)]
enum AnError {
2018-03-28 08:41:58 +00:00
#[fail(
display = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
)]
2017-11-27 04:49:53 +00:00
UnexpectedSingleToken { token: syn::Token },
}
2017-11-27 11:53:54 +00:00
// #2193
enum WidthOf101 {
#[fail(display = ".....................................................")]
Io(::std::io::Error),
2017-11-27 11:53:54 +00:00
#[fail(display = ".....................................................")]
Ioo(::std::io::Error),
Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(::std::io::Error),
Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(
::std::io::Error,
),
}
// #2389
pub enum QlError {
#[fail(display = "Parsing error: {}", 0)]
LexError(parser::lexer::LexError),
#[fail(display = "Parsing error: {:?}", 0)]
ParseError(parser::ParseError),
#[fail(display = "Validation error: {:?}", 0)]
ValidationError(Vec<validation::Error>),
#[fail(display = "Execution error: {}", 0)]
ExecutionError(String),
// (from, to)
#[fail(display = "Translation error: from {} to {}", 0, 1)]
TranslationError(String, String),
// (kind, input, expected)
#[fail(
display = "aaaaaaaaaaaaCould not find {}: Found: {}, expected: {:?}",
2018-09-29 23:04:34 +00:00
0, 1, 2
)]
ResolveError(&'static str, String, Option<String>),
}
2018-04-28 04:23:50 +00:00
// #2594
enum Foo {}
enum Bar {}
// #3562
enum PublishedFileVisibility {
Public =
sys::ERemoteStoragePublishedFileVisibility_k_ERemoteStoragePublishedFileVisibilityPublic,
FriendsOnly = sys::ERemoteStoragePublishedFileVisibility_k_ERemoteStoragePublishedFileVisibilityFriendsOnly,
Private =
sys::ERemoteStoragePublishedFileVisibility_k_ERemoteStoragePublishedFileVisibilityPrivate,
}
// #3771
//#![feature(arbitrary_enum_discriminant)]
#[repr(u32)]
pub enum E {
A {
a: u32,
} = 0x100,
B {
field1: u32,
field2: u8,
field3: m::M,
} = 0x300, // comment
}