-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Consider redefining the places ~const
bounds are allowed
#102497
Comments
Why can't we just forbid it on non const assoc fns? |
Yes we can. I was also thinking about |
Ah yea, seems ok as long as we have an |
I think that would make a lot of const code a bit cleaner. |
I tried implementing this with effects, but it's a bit messy. Right now, we desugar impl SomeType {
const fn foo<T: ~const Trait>() {}
} to impl SomeType {
fn foo<effect C: constness, T: Trait<C>>() {}
} but in order to allow impl<T: ~const Tr> SomeType {
const fn foo() {}
} to use the impl<effect C: constness, T: Tr<C>> SomeType {
const fn foo() {}
fn bar() {}
} but then non-const fns like |
Can we ignore the constness effect in non-const contexts? |
The current design treats the presence of a constness effect as the source of truth for whether a function is |
At #102409 (comment), it was pointed out that associated functions can have
~const
bounds even though they may be non-const. We need to figure out and define what places~const
should be allowed. Note that since~const
only applies more restrictions on callers that areconst
, putting them onnon-const
fn
s has no effect.The text was updated successfully, but these errors were encountered: