Fix #[derive] for empty tuple structs/variants#35728
Conversation
src/libsyntax/ext/build.rs
Outdated
There was a problem hiding this comment.
Alternatively I can change interface of the builder and split pat_enum into pat_path/pat_tuple_struct, that would be a more disruptive change.
There was a problem hiding this comment.
Serde does not use PatKind so we are not affected.
I don't understand this method. Below, pat_struct produces PatKind::Struct and pat_tuple produces PatKind::Tuple. Why does pat_enum mean PatKind::TupleStruct? Can't enum variants be structs too? Also for the empty case why pick empty PatKind::Struct over empty PatKind::TupleStruct?
There was a problem hiding this comment.
Why does pat_enum mean PatKind::TupleStruct? Can't enum variants be structs too?
The name pat_enum is pretty old, from times when braced enum variants Variant{..} were unstable and empty braced structs/variants Variant{} didn't exist, it means either TupleVariant(..) or UnitVariant.
Also for the empty case why pick empty PatKind::Struct over empty PatKind::TupleStruct?
Because it matches anything (see rust-lang/rfcs#1506 for more details).
The alternative I mentioned above (pat_enum -> pat_path/pat_tuple_struct) is much cleaner at cost of larger breakage. I will probably implement it instead.
|
r=me |
8a0ad66 to
f6e06a8
Compare
|
Updated with |
Fix #[derive] for empty tuple structs/variants This was missing from rust-lang#35138
Batch up libsyntax breaking changes Batch of the following syntax-[breaking-change] changes: - #35591: Add a field `span: Span` to `ast::Generics`. - #35618: Remove variant `Mod` of `ast::PathListItemKind` and refactor the remaining variant `ast::PathListKind::Ident` to a struct `ast::PathListKind_`. - #35480: Change uses of `Constness` in the AST to `Spanned<Constness>`. - c.f. `MethodSig`, `ItemKind` - #35728: Refactor `cx.pat_enum()` into `cx.pat_tuple_struct()` and `cx.pat_path()`. - #35850: Generalize the elements of lists in attributes from `MetaItem` to a new type `NestedMetaItem` that can represent a `MetaItem` or a literal. - #35917: Remove traits `AttrMetaMethods`, `AttributeMethods`, and `AttrNestedMetaItemMethods`. - Besides removing imports of these traits, this won't cause fallout. - Add a variant `Union` to `ItemKind` to future proof for `union` (c.f. #36016). - Remove inherent methods `attrs` and `fold_attrs` of `Annotatable`. - Use methods `attrs` and `map_attrs` of `HasAttrs` instead. r? @Manishearth
This was missing from #35138
plugin-[breaking-change]
r? @Manishearth