diff options
| author | bors <bors@rust-lang.org> | 2021-05-15 14:55:56 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-05-15 14:55:56 +0000 |
| commit | eac3c7c5bd38ec38062ebde475bd2ea6317d0c09 (patch) | |
| tree | b57dd71626453dfe3346ebae075e9882d88cc3e2 /src/tools/rustfmt/tests/target/enum.rs | |
| parent | 2a245f40a19c9a60b3be33c959eb5cfb0ad163c6 (diff) | |
| parent | 34368ec2aaa4362a1f850cc1610d0a17e60d37b5 (diff) | |
| download | rust-eac3c7c5bd38ec38062ebde475bd2ea6317d0c09.tar.gz rust-eac3c7c5bd38ec38062ebde475bd2ea6317d0c09.zip | |
Auto merge of #82208 - jyn514:rustfmt-subtree, r=Mark-Simulacrum
Convert rustfmt from a submodule to a subtree r? `@calebcartwright` cc `@Manishearth` `@Mark-Simulacrum` The motivation is that submodule updates cause rustfmt to not be available on nightly a lot; most recently it was unavailable for over 10 days, causing the beta release to be delayed. Additionally this is much less work on the part of the rustfmt maintainers to keep the rustfmt compiling, since now people making breaking changes will be responsible for fixing them. I kept the rustfmt git history so it looks like there are thousands of commits. The important commits are https://github.com/rust-lang/rust/compare/851dee3af9404bf399c3c4ffefe5105edb3debad~..pull/82208/head. This adds about 10 MB of git history, which is not terribly much compared to the 702 MB that already exist. - Add `src/tools/rustfmt` to `x.py check` - Fix CRLF issues with rustfmt tests (see commit for details) - Use `rustc_private` instead of crates.io dependencies This was already switched upstream and would have landed in the next submodule bump anyway. This just updates Cargo.lock for rust-lang/rust. - Add `yansi-term` to the list of allowed dependencies. This is a false positive - rustc doesn't actually use it, only rustfmt, but because it's activated by the cargo feature of a dependency, tidy gets confused. It's fairly innocuous in any case, it's used for color printing. This would have happened in the next submodule bump. - Remove rustfmt from the list of toolstate tools. - Give a hard error if testing or building rustfmt fails. - Update log to 0.4.14 This avoids a warning about semicolons in macros; see the commit for details. - Don't add tools to the sysroot when they finish building. This is the only change that could be considered a regression - this avoids a "colliding StableCrateId" error due to a bug in resolve (https://github.com/rust-lang/rust/issues/56935). The regression is that this rebuilds dependencies more often than strictly necessary. See the commit for details. Fixes https://github.com/rust-lang/rust/issues/85226 (permanently). Closes https://github.com/rust-lang/rust/issues/82385. Helps with https://github.com/rust-lang/rust/issues/70651. Helps with https://github.com/rust-lang/rust/issues/80639.
Diffstat (limited to 'src/tools/rustfmt/tests/target/enum.rs')
| -rw-r--r-- | src/tools/rustfmt/tests/target/enum.rs | 289 |
1 files changed, 289 insertions, 0 deletions
diff --git a/src/tools/rustfmt/tests/target/enum.rs b/src/tools/rustfmt/tests/target/enum.rs new file mode 100644 index 00000000000..9a25126b44e --- /dev/null +++ b/src/tools/rustfmt/tests/target/enum.rs @@ -0,0 +1,289 @@ +// rustfmt-wrap_comments: true +// Enums test + +#[atrr] +pub enum Test { + A, + B(u32, A /* comment */, SomeType), + /// Doc comment + C, +} + +pub enum Foo<'a, Y: Baz> +where + X: Whatever, +{ + A, +} + +enum EmtpyWithComment { + // Some comment +} + +// C-style enum +enum Bar { + A = 1, + #[someAttr(test)] + B = 2, // comment + C, +} + +enum LongVariants { + First( + LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOONG, // comment + VARIANT, + ), + // This is the second variant + Second, +} + +enum StructLikeVariants { + Normal(u32, String), + StructLike { + x: i32, // Test comment + // Pre-comment + #[Attr50] + y: SomeType, // Aanother Comment + }, + SL { + a: A, + }, +} + +enum X { + CreateWebGLPaintTask( + Size2D<i32>, + GLContextAttributes, + IpcSender<Result<(IpcSender<CanvasMsg>, usize), String>>, + ), // This is a post comment +} + +pub enum EnumWithAttributes { + //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> +where + I: Iterator<Item = T>, +{ + // Pre Comment + Left { list: I, root: T }, // Post-comment + Right { list: I, root: T }, // Post Comment +} + +enum EmtpyWithComment { + // Some comment +} + +enum TestFormatFails { + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, +} + +fn nested_enum_test() { + if true { + enum TestEnum { + One( + usize, + usize, + usize, + usize, + usize, + usize, + usize, + usize, + usize, + usize, + usize, + usize, + usize, + usize, + usize, + usize, + ), /* AAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAA + * AAAAAAAAAAAAAAAAAAAAAA */ + Two, /* AAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + * AAAAAAAAAAAAAAAAAA */ + } + enum TestNestedFormatFail { + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, + } + } +} + +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 { + SetCookieForUrl( + ServoUrl, + #[serde( + deserialize_with = "::hyper_serde::deserialize", + serialize_with = "::hyper_serde::serialize" + )] + Cookie, + CookieSource, + ), +} + +enum Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong +{} +enum Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong +{} +enum Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong +{} +enum Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong +{ + Foo, +} + +// #1046 +pub enum Entry<'a, K: 'a, V: 'a> { + Vacant(#[stable(feature = "rust1", since = "1.0.0")] VacantEntry<'a, K, V>), + Occupied(#[stable(feature = "rust1", since = "1.0.0")] OccupiedEntry<'a, K, V>), +} + +// #2081 +pub enum ForegroundColor { + CYAN = + (winapi::FOREGROUND_INTENSITY | winapi::FOREGROUND_GREEN | winapi::FOREGROUND_BLUE) as u16, +} + +// #2098 +pub enum E<'a> { + V(<std::slice::Iter<'a, Xxxxxxxxxxxxxx> as Iterator>::Item), +} + +// #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, +} + +// #2190 +#[derive(Debug, Fail)] +enum AnError { + #[fail( + display = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + )] + UnexpectedSingleToken { token: syn::Token }, +} + +// #2193 +enum WidthOf101 { + #[fail(display = ".....................................................")] + Io(::std::io::Error), + #[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: {:?}", + 0, 1, 2 + )] + ResolveError(&'static str, String, Option<String>), +} + +// #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 +} |
