-
Notifications
You must be signed in to change notification settings - Fork 13.8k
feat: add parsing support for algebraic effect declarations #146821
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
feat: add parsing support for algebraic effect declarations #146821
Conversation
Add 'effect' keyword to token system and parser Add Effect AST node with operations as ThinVec<Box<FnSig>> Implement parse_item_effect and parse_effect_operation functions Support effect declarations with generics, where clauses, and operation signatures Fix delimited parsing logic to properly handle comma-separated operations Validate parsing with tests for empty effects, single/multiple operations, and complex syntax This establishes the foundation for algebraic effects in Rust by enabling the compiler to parse effect declarations like effect Foo<T> { op(x: T) -> T; }.
Some changes occurred in compiler/rustc_passes/src/check_attr.rs |
The job Click to see the possible cause of the failure (guessed by this bot)
|
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.
I am not aware of any official motions to add algebraic effects to the language, not even experimentally.
No same, was taking a quick look because of the ping I got but this is not something we should merge. Though I welcome you to experiment with this in a fork for example, I think we should close this |
@qxlsz Not to discourage you from future contributions to rustc but adding new features to the language and the compiler, especially large and non-trivial ones like algebraic effects, isn't as simple as opening a PR to this repo. For comparison, even medium-sized features need at least an approved lang experiment (see). However, for large ones like this one, at the very least you should definitely seek contact with Rust project members first (e.g., on Zulip in the #t-lang or in the #t-lang/effects channel) to get a rough vibe check and since this needs a bunch of design questions answered first (parsing is the least of our worries). I would say it doesn't need an RFC upfront but at least a somewhat thought out design document or pre-RFC would be highly beneficial and customary if you really want to pursue this. All that said, I want to warn you that it's probably not going to be easy to convince enough relevant people to make this an immediate project goal but that's just my personal hunch. Last time this was proposed was in rust-lang/rfcs#73 and even 10 years later, rust-lang/rfcs#73 (comment) is still relevant in a way. Okay, to be totally honest, T-lang did have a bunch of meetings pertaining to effects in the last year as part of the "effects initiative". However, I don't remember the current stance being anywhere close to "let's introduce algebraic effects". We're trying to make const trait impls happen as soon as possible, that's our priority in that area. For the general feature of algebraic effects, you'd need to be able to explain how they're supposed to be represented in Rust's type system and what their runtime semantics should be (cc zero-overhead abstractions, etc.). |
Since this won't be actionable anytime soon, I'll close this PR now. Thanks for your understanding! |
Agreed. |
No description provided.