-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Constify Fn*
traits
#143640
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
base: master
Are you sure you want to change the base?
Constify Fn*
traits
#143640
Conversation
deferred_call_resolution.resolve(self); | ||
deferred_call_resolution.resolve(&mut FnCtxt::new( | ||
self, | ||
self.param_env, | ||
closure_def_id, | ||
)); |
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.
This was necessary, as otherwise
const FOO: impl Fn() = || {
let x = || ();
x()
};
would have performed some checks in the outer closure's body as if it were const, causing the x()
invocation to fail because x
is not a const closure
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.
This ICE test didn't seem like it was still testing anything meaningful
Can you add new solver support too? |
Please also remove the hack from typeck around |
you already added that and it was never removed. I made the tests run on both solvers |
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.
lgtm
r=me when ci |
@bors r=compiler-errors |
@@ -72,7 +72,8 @@ use crate::marker::Tuple; | |||
)] | |||
#[fundamental] // so that regex can rely that `&str: !FnMut` | |||
#[must_use = "closures are lazy and do nothing unless called"] | |||
// FIXME(const_trait_impl) #[const_trait] | |||
#[const_trait] | |||
#[rustc_const_unstable(feature = "const_trait_impl", issue = "67792")] |
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.
Shouldn't we have a proper lib feature and tracking issue here, rather than slapping everything into a 5-year-old issue that was created for an entirely different generation of the const trait RFC evolution?
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.
The lang feature is not very useful without the lib feature, requiring separate lib features for different traits is just going to require one to add many features when using any somewhat large feature.
We could pick a new tracking issue, but that also just feels like shuffling things around for no good reason.
I have no idea what the process will be for stabilizing any of these, a lot of them are entangled. We'll likely want to stabilize many traits as const together with stabilizing the lang feature to not cause weird ecosystem churn
r? @compiler-errors @fee1-dead
this should unlock a few things. A few
const_closures
tests have broken even more than before, but that feature is marked as incomplete anyway