-
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
implement Default
for all arrays
#84838
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
ok, we definitely need to use We only consider the auto trait impl if the manual impl does not shallowly match. So if our manual impl has a ty param as the self type, we never actually use the auto trait one. If we manually impl the |
Is there a reason why this has to add extra lang items? Why not just use I'm a bit confused why the N = 0 case is a problem, |
|
Worth noting that with |
Could you? I was under the impression specialization on const generics was more complicated/unimplemented/at least requires |
Yeah, looks like currently on nightly this doesn't work. I would think that this could be done in the future, though. My point of it being temporary in the long-term is still relevant.
|
We discussed this in the const generics meeting this morning. This intersects and somewhat constraints specialization in that it uses a lang-item to effectively simulate a pair of impls:
This cannot be covered by the specialization plans as they stand today. It is conceivable, though, to imagine accepting it in the future. The key would be that we don't need to know whether There would be a problem if you have a further impl like |
I'm going to nominate for @rust-lang/lang discussion on the previous comment. |
☔ The latest upstream changes (presumably #84730) made this pull request unmergeable. Please resolve the merge conflicts. |
We discussed this in today's @rust-lang/libs-api meeting, and we're in favor of having this |
From a library implementation perspective: The code that this PR adds in |
So in our @rust-lang/lang meeting on 2021-06-29, we discussed this proposal again, and in particular we discussed @m-ou-se's implementation concerns. Our sense is that we feel comfortable with the idea of |
Using
feature(marker_trait_attr)
and a new lang itemarray_default_hack
, we're able to implementDefault
for generic arrays without relying on any too unstable features.cc https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/array.20default.20impls
r? @nikomatsakis 💖