Skip to content

Make struct-like enum variants experimental #9305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
brson opened this issue Sep 19, 2013 · 7 comments
Closed

Make struct-like enum variants experimental #9305

brson opened this issue Sep 19, 2013 · 7 comments

Comments

@brson
Copy link
Contributor

brson commented Sep 19, 2013

Using #9304.

Nominating backcompat.

@catamorphism
Copy link
Contributor

accepted backwards-compatible

@thestinger
Copy link
Contributor

By struct-like enum variants do you mean ones with named fields?

@alexcrichton
Copy link
Member

Yeah, this should be experimental:

enum A {
  Variant1 { foo: int }
}

@thestinger
Copy link
Contributor

Would it be marked experimental because we're not sure if we want to commit to supporting it? As far as I know the implementation is shared with structs in adt.rs.

@SiegeLord
Copy link
Contributor

I think struct variants have an important use case for variants with many fields. Consider code like this: https://github.com/brson/rust-sdl/blob/master/src/event.rs#L577 and https://github.com/mozilla/rust/blob/master/src/libsyntax/ast.rs#L227 . In both cases they would benefit greatly from having the variant arguments have explicit names, e.g. consider this code from my library which mirrors the rust-sdl use case: https://github.com/SiegeLord/RustAllegro/blob/master/src/events.rs#L79 and https://github.com/SiegeLord/RustAllegro/blob/master/example.rs#L39 . It seems a lot clearer than the equivalent rust-sdl code: https://github.com/brson/rust-sdl/blob/master/demo/video.rs#L38 .

@sfackler
Copy link
Member

I've also found these extremely useful, especially in cases like https://github.com/sfackler/rust-postgres/blob/master/src/message.rs#L73

@brson
Copy link
Contributor Author

brson commented Sep 25, 2013

The thinking was that they were broken. Maybe they aren't.

alexcrichton added a commit to alexcrichton/rust that referenced this issue Oct 3, 2013
A few features are now hidden behind various #[feature(...)] directives. These
include struct-like enum variants, glob imports, and macro_rules! invocations.

Closes rust-lang#9304
Closes rust-lang#9305
Closes rust-lang#9306
Closes rust-lang#9331
flip1995 pushed a commit to flip1995/rust that referenced this issue Mar 20, 2025
)

Closes rust-lang#13306
Closes rust-lang#9925
Closes rust-lang#9470
Closes rust-lang#9305

Clippy gives wrong suggestions when the key is not `Copy`. As suggested
in rust-lang#9925, in such cases Clippy will simply warn but no fix.

changelog: [`map_entry`]: fix wrong suggestions when key is not `Copy`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants