-
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 feature(const_generics_defaults)
#75384
Conversation
☔ The latest upstream changes (presumably #75383) made this pull request unmergeable. Please resolve the merge conflicts. |
Hmm, I am not sure how easy it is to start here and think that's it's probably better to start by actually parsing Do we want to implement this as part of Also, while I will review this, I won't merge it myself, so r? @varkor |
ce46be1
to
705cbf7
Compare
I think if we're going to make any progress with defaults for const generics, we ought to try to implement them in a single PR, or at least bigger steps than this. Otherwise we risk making implementation choices that aren't the best in practice, and then refactoring unnecessarily later. You're welcome to try implementing defaults, though: I think we'll want an extra feature flag |
Hm I think I added all the points where I saw the |
Oh, sorry, I hadn't actually looked at the changes yet. Maybe this actually isn't too far off a minimal working implementation? Maybe if you tried implementing the parser changes, we could get a better idea of what does or doesn't work? |
34c40c6
to
052e043
Compare
☔ The latest upstream changes (presumably #75609) made this pull request unmergeable. Please resolve the merge conflicts. |
Hm I'm a little stuck at this point, I'm not particularly sure where the error could be originating from. |
@JulianKnodt - ping from triage, can you please address the merge conflicts? |
6c0b4ca
to
2ab5e69
Compare
📌 Commit 33370fd has been approved by |
@bors retry |
⌛ Testing commit 33370fd with merge c964c9ae35ee07abd1712a8f902a6f3852d059bb... |
💔 Test failed - checks-actions |
@bors retry |
☀️ Test successful - checks-actions |
@JulianKnodt: thank you for all your hard work pushing this feature to completion! |
@JulianKnodt @varkor - there was a slight performance regression seen after a performance run of this change. It's fairly small and it only impacts one benchmark which does not use const generics at all. The specific query impacted is |
Probably CGU partitioning changed after the queries changed? |
I'd also say this is expected perf change given what this does. |
Implements const generics defaults
struct Example<const N: usize=3>
, as well as a query for getting the default of a given const-parameter's def id. There are some remaining FIXME's but they were specified as not blocking for merging this PR. This also puts the defaults behind the unstable feature gate#![feature(const_generics_defaults)]
.This currently creates a field which is always false onGenericParamDefKind
for future use whenconsts are permitted to have defaults. I'm not sure if this is exactly what is best for adding default parameters, but I mimicked the style of type defaults, so hopefully this is ok.
r? @lcnr