-
Notifications
You must be signed in to change notification settings - Fork 0
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
Const stability on impls doesn't make sense #5
Comments
The dilemma here is that we allow |
Notice how, on 1.65: #![feature(const_trait_impl)]
use std::ops::Add;
use std::marker::Destruct;
const fn foo(t: i32, t2: i32) {
Add::add(t, t2);
}
const fn test() {
foo(1, 2);
} errors with:
But I can write: #![feature(const_trait_impl)]
use std::ops::Add;
use std::marker::Destruct;
const fn foo<T: ~const Add<Output = T> + ~const Destruct>(t: T, t2: T) {
Add::add(t, t2);
}
const fn test() {
foo(1, 2);
} and it works totally fine. |
Why should we repeat the mistake? We should disallow both, since they can't reasonably have an effect with the current solver. |
Regarding the examples -- we can stage the rollout of const trait in various ways:
It's hard for me to say how much granularity we will need. |
I think (2.) makes sense. Thinking about what additional stability guarantees should be imposed to fix this:
|
For now, I guess we can just always require const traits and impls to be const-unstable (either explicitly, or implicitly via |
Okay, I opened #16 for some more concrete discussion of how that could look like. |
Const stability on impls makes no sense in the same way that stability on impls makes no sense, since you can always put a const call behind some generic type parameter and only see the impl after substitution/monomorphization.
We currently have code in the MIR const validation to handle const impls, and we shouldn't.
The text was updated successfully, but these errors were encountered: