-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Tracking issue for "clarified ADT kinds" (RFC 1506) #35626
Comments
Implement RFC 1506 "Clarify the relationships between various kinds of structs and variants" cc #35626
@rfcbot fcp merge I propose that we stabilize this feature. There are no known blockers or interactions and it is a relatively minor extension to existing syntax. I would very much welcome the ability to use |
FCP proposed with disposition to merge. Review requested from: No concerns currently listed. |
All relevant subteam members have reviewed. No concerns remain. |
It has been one week since all blocks to the FCP were resolved. |
Entering FCP. Honestly I'm not clear for how long. =) Stabilizations still confuse me a bit. |
The release is coming up, and this has not exactly been a controversial topic, so we've decide to make it official and approve this for stabilization. |
Partially stabilize RFC 1506 "Clarify relationships between ADTs" Lifted restrictions on tuple structs/variants are stabilized, i.e. `S{..}` can be used with any structs and empty tuple structs are permitted without feature gate. Numeric fields in struct expressions/patterns `S { 0: a, 1: b }` are **NOT** stabilized. This was implemented 1.5 months ago in Rust 1.12, but this is a tiny technical change that could probably go even without RFC/stabilization period. cc rust-lang#35626 rust-lang#36871 r? @nikomatsakis
@rfcbot fcp merge I'd like to propose that we stabilize the remaining feature in this feature-gate, numeric field names. For example, this code works now: #![feature(relaxed_adts)]
struct Foo(u32);
fn main() {
let Foo { 0: x } = Foo(22);
println!("{}", x);
} |
@nikomatsakis It looks like the rfcbot ignored your second merge request and nobody noticed for a month. Maybe it can't handle two fcp merges on the same issue? |
cc @rust-lang/lang, since RFC bot doesn't allow us to FCP again, I'll make the list manually. @nikomatsakis proposed to go to FCP for stabilizing the numeric field names feature. |
See rust-lang/rfcs#902 (comment) for one more possible motivation for numeric fields in patterns. |
cc @withoutboats @pnkfelix -- stabilizing numeric field names? |
@rfcbot reviewed FWIW I personally hate this and would never use it. I think its the kind of thing we can all politely disagree about though. :-) |
Had we went with some of the other suggestions, |
All reviewed now. @rfcbot seems to be on PTO, so I'm going to manually declare that this issue is entering Final Comment Period for 3 weeks (until Feb 1). |
Fwiw (as I already expressed in a comment on the RFC iirc), I think the |
And as far as I can tell, this is still not possible? (I was going to ask, "at least we don't allow declaring non-contiguous numeric fields, right?", and as far as that goes, apparently we don't.) |
I agree that numeric field patterns seem actively detrimental for hand-written code, but I believe the main motivation is to make life easier for various kinds of code generation by increasing overall uniformity (or, put differently, removing somewhat pedantic distinctions between kinds of |
Hmm. I am sympathetic but I do think there is a need to consolidate tuple/field structs into one logical structure, as well as to enable macros that work uniformly over them. I actually think we should support struct declarations like |
Doesn't that run into type namespace vs. value namespace issues for the constructor, for the record? I do agree that if we allow one we should also allow the other, otherwise. (As long as |
Doesn't what run into said conflicts, exactly? (I would assume that if you wrote |
I don't know, numeric fields in expressions/patterns, while mostly useless, at least refer to something already existsing and useful - fields of tuple structs. |
@petrochenkov Not totally useless; it would let you replace a tuple-struct with a modified constructor, for example, without disturbing existing code. e.g. transforming pub struct Foo(pub usize); into pub struct Foo {
0: usize
}
pub fn Foo(x: usize) -> Foo { Foo { 0: x * 2 } } But anyway I don't feel a burning desire to add it. Just saying that it doesn't seem a priori out of the question to me. |
There're still tuple struct patterns |
@petrochenkov true; my feeling is that those should desugar to |
@nikomatsakis FCP complete? (Pinging since @rfcbot seems to still be on PTO for this issue.) |
@scottmcm Yeah, I think we're ready to stabilize; while there's been some discussion since FCP, it's mostly been clarifying technical details or motivation, rather than bringing new tradeoffs to light. |
cc @petrochenkov @rust-lang/compiler -- anyone want to make a quick stabilization PR that we can backport to 1.17 beta? |
Stabilization is a great place for a first PR. There are directions available on the forge: https://forge.rust-lang.org/stabilization-guide.html Marking this as E-easy and E-mentor. |
Ah, an important question -- has this been documented? If so, we ought to do that first. |
I do not believe so. |
…henkov Stabilize rfc 1506 - Clarified ADT Kinds Closes #35626 Documentation: - [ ] Reference rust-lang/reference#37 - [ ] Book? - [ ] Rust by example?
cc #42945 |
Tracking issue for rust-lang/rfcs#1506.
Status:
Fully stabilized.
Stabilized by PR #41145:
Stabilized by PR #36868:
The text was updated successfully, but these errors were encountered: