-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
dont provide fwd declared params to cg defaults #86580
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while this does work for now, we probably want to implement these changes in generics_of
instead to deal with the ParamEnv
. We will need to do that to deal with unused substs in general.
I don't have a strong opinion on whether to merge this as is, so r=me if you think that it's desirable
(this PR needs the code to be wrapped in a edit: Done, and changes have been moved to generics_of and explicit_predicates_of |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@bors r+ |
📌 Commit abfd44d has been approved by |
dont provide fwd declared params to cg defaults Fixes rust-lang#83938 ```rust #![feature(const_evaluatable_checked, const_generics, const_generics_defaults)] #![allow(incomplete_features)] pub struct Bar<const N: usize, const M: usize = { N + 1 }>; pub fn foo<const N1: usize>() -> Bar<N1> { loop {} } fn main() {} ``` This PR makes this code no longer ICE, it was ICE'ing previously because when building substs for `Bar<N1>` we would subst the anon ct: `ConstKind::Unevaluated({N + 1}, substs: [N, M])` with substs of `[N1]`. the anon const has forward declared params supplied though so we end up trying to substitute the provided `M` param which causes the ICE. This PR doesn't handle the predicates of the const so ```rust trait Foo<const N: usize> { const Assoc: usize; } pub struct Bar<const N: usize = { <()>::Assoc }> where (): Foo<N>; ``` Resolves to `<() as Foo<N>>::Assoc` which can allow for using fwd declared params indirectly. ```rust trait Foo<const N: usize> {} struct Bar<const N: usize = { 2 + 3 }> where (): Foo<N>; ``` This code also ICEs under this PR because instantiating the default's predicates causes an ICE as predicates_of contains predicates with fwd declared params PR was briefly discussed [in this zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/evil.20preds.20in.20param.20env.20.2386580)
⌛ Testing commit abfd44d with merge deab484024a324406ff1c8984f240ec0334a65a3... |
@bors retry |
⌛ Testing commit abfd44d with merge 8e3359c9c54ca446b64a0aa00316f3f42fcda67a... |
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
@bors retry |
@bors r=nikomatsakis |
📌 Commit d1e5e72 has been approved by |
☀️ Test successful - checks-actions |
Fixes #83938
This PR makes this code no longer ICE, it was ICE'ing previously because when building substs for
Bar<N1>
we would subst the anon ct:ConstKind::Unevaluated({N + 1}, substs: [N, M])
with substs of[N1]
. the anon const has forward declared params supplied though so we end up trying to substitute the providedM
param which causes the ICE.This PR doesn't handle the predicates of the const so
Resolves to
<() as Foo<N>>::Assoc
which can allow for using fwd declared params indirectly.This code also ICEs under this PR because instantiating the default's predicates causes an ICE as predicates_of contains predicates with fwd declared params
PR was briefly discussed in this zulip thread