-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Calling methods on generic parameters of const fns #2632
Conversation
One alternative syntax design that is not mentioned here is the question of There are strong arguments that Conversely, as far as I'm aware, (I don't like to start the discussion with syntax bikeshedding, but as mentioned in the original post, this RFC has already ungone significant design discussion and I'm satisfied it's close to the optimal conservative design.) |
How do we want |
I imagine it makes most sense to use the same (syntactic) rules for |
This comment has been minimized.
This comment has been minimized.
Co-Authored-By: oli-obk <[email protected]>
I'm not sure why {
let local = get_thing();
// Implicitly inserted
// (each one is individually omitted if that type
// does not explicitly implement Drop)
Drop::drop(&mut local);
Drop::drop(&mut local.field_1);
Drop::drop(&mut local.field_2);
} Requiring (one could argue that allowing |
It has been mentioned before. This was even the original syntax. Reasoning for the change can be found at rust-lang/const-eval#8 (comment) cc @scottmcm for consistency (not in semantics, but user expectations) I have slowly come back around to |
Ultimately the location of Conceptually, the keyword is attached to the trait. I.e. it's not an |
I think that's looking at it from the wrong perspective. It's not that it's |
But as far as I can tell, the Constness is not a property of the Trait, but of the impl, which is not the same for dyn, right? |
I agree with this in particular when viewed in light of effect systems. Moreover,
Traits can be seen as logical requirements and implementations are proofs that those requirements are satisfied. In that light, e.g. |
Co-Authored-By: oli-obk <[email protected]>
That sounds like something that belongs in the "future extensions" section. It sounds like something that may be desirable for guarantees similar to |
A problem came up with the original plan, described in rust-lang/rust#83452 and on Zulip: under some conditions, we currently accept |
Should we try to revert that support, @RalfJung? I think it was accidental. |
@nikomatsakis That might be good if we want to keep our options open -- but @oli-obk has the overview here, I'm just reporting what came up elsewhere. I don't currently have the bandwidth to work on this. I personally am leaning towards a different design than the one proposed in the RFC, one where there is no implicit "callable in const context" -- that would be more consistent with |
What's the status of the RFC? FCP was proposed over two years ago, and is currently blocked by @withoutboats. I will note that boats is an alumnus of the lang team. While I am not dismissing their concerns outright, they have had zero public activity on GitHub in over six months. At this point, is it worth cancelling and restarting the checkboxes? This would permit the current lang team to register the same concerns if they still exist. cc lang team: @joshtriplett @nikomatsakis @cramertj @pnkfelix @scottmcm |
I'd assume experimentation going on based upon #2632 (comment) ? If I read correctly, there was a rather extensive discussion around boats' third issue, which prompted a desire to experiment. |
Yeah, the main reason I asked is because said experimentation had taken place and been on nightly for a while now. |
There are currently still a few things that make the experimental feature useless in practice. We don't have the implementation capacity right now to work on it, but I do plan on more things happening here this year. |
I talked to @oli-obk today and we agreed that we will close this RFC for now. The content is likely still desired but we want to do more experimentation and will re-open when the design seems closer to settled. |
IIUC, this RFC would make trait-associated constants unusable in const contexts if the trait bound is not declared trait Foo {
fn foo(value: u8) -> u8;
}
trait Bar {
const BAR: u8;
fn bar(value: u8) -> u8;
}
const fn baz<T>() -> u8
where T: Foo + ?const Bar {
T::foo(T::BAR) // error: `<T as Bar>` used in a const context
} |
TLDR: Allow
and
cc @Centril @varkor @RalfJung @eddyb
This RFC has gone through an extensive pre-RFC phase in rust-lang/const-eval#8
Rendered
Triage: pFCP comment: #2632 (comment)