-
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 Self and associated types in struct expressions and patterns #37544
Comments
This doesn't feel complete to me without also allowing I was looking forward to this feature, so I don't have to repeat type names in as many places, but in its current state this is too inconsistent to be widely applicable. |
|
👍
I don't want to get off-topic here, but I find it odd that a type alias does not give you the full capabilities that you can do when using the original type name. When one says |
It's possible, just messy.
It may a function call, or it may be a tuple struct construction. If the "type itself" is used for looking up tuple struct constructors, then we need:
Instead of doing all this, tuple/unit structs define additional function/constant-like items in value namespace which then used during resolution of |
Feature gate Self and associated types in struct expressions and patterns cc rust-lang#37544 Fixes rust-lang#37035 (comment) r? @nikomatsakis
@rfcbot fcp merge I propose that we stabilize this tracking issue. This is the feature which allows you to use My main concern is that perhaps it is confusing to allow types (and not just structs) at all! I am open to the possibility of letting this bake a little longer and not moving to FCP. |
Team member @nikomatsakis has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
I like this feature and even look forward to having it integrated with variant types! |
This is my concern too, however, my understanding is that this ship sailed some time ago and we allow all sorts of things in the ident position of a struct literal. |
Off hand I'm not sure what you mean... have an example? Do we allow e.g. type aliases? |
@nikomatsakis We do allow type aliases and this is what I had in mind. FWIW, we also allow, e.g., |
So in particular this does work: struct Foo<T> { x: T }
type Bar = Foo<u32>;
fn main() {
let x = Bar { x: 22 };
} |
@rfcbot reviewed |
ping @nikomatsakis |
@petrochenkov We can backport the stabilization. Looks like this was blocked on @pnkfelix who's been on vacation. I'll try to get a hold of him now. |
@rfcbot reviewed |
🔔 This is now entering its final comment period, as per the review above. 🔔 psst @nikomatsakis, I wasn't able to add the |
The final comment period is now complete. |
@petrochenkov you want to prepare stabilization PR? |
1 similar comment
@petrochenkov you want to prepare stabilization PR? |
Stabilize Self and associated types in struct expressions and patterns Rebase of #37734 Closes #37544 r? @nikomatsakis
I'm going to add a feature gate according to #37035 (comment), this is a corresponding tracking issue.
The text was updated successfully, but these errors were encountered: