Skip to content

Conversation

qxlsz
Copy link

@qxlsz qxlsz commented Sep 20, 2025

No description provided.

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; }.
@rustbot
Copy link
Collaborator

rustbot commented Sep 20, 2025

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann

@rustbot rustbot added the A-attributes Area: Attributes (`#[…]`, `#![…]`) label Sep 20, 2025
@rustbot rustbot added A-meta Area: Issues & PRs about the rust-lang/rust repository itself S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 20, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 20, 2025

r? @jackh726

rustbot has assigned @jackh726.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling cc v1.2.0
error: expected identifier, found keyword `with`
    --> library/core/src/ptr/non_null.rs:1231:36
     |
1231 |     pub const unsafe fn swap(self, with: NonNull<T>)
     |                                    ^^^^ expected identifier, found keyword
     |
help: escape `with` to use it as an identifier
     |
1231 |     pub const unsafe fn swap(self, r#with: NonNull<T>)
     |                                    ++

error: expected expression, found keyword `with`
    --> library/core/src/ptr/non_null.rs:1236:43
     |
1236 |         unsafe { ptr::swap(self.as_ptr(), with.as_ptr()) }
     |                                           ^^^^ expected expression

error: expected identifier, found keyword `with`
    --> library/core/src/ptr/mut_ptr.rs:1504:36
     |
1504 |     pub const unsafe fn swap(self, with: *mut T)
     |                                    ^^^^ expected identifier, found keyword
     |
help: escape `with` to use it as an identifier
     |
1504 |     pub const unsafe fn swap(self, r#with: *mut T)
     |                                    ++

error: expected expression, found keyword `with`
    --> library/core/src/ptr/mut_ptr.rs:1509:29
     |
1509 |         unsafe { swap(self, with) }
     |                             ^^^^ expected expression

[RUSTC-TIMING] build_script_build test:false 0.138
   Compiling std v0.0.0 (/checkout/library/std)
[RUSTC-TIMING] build_script_build test:false 0.230

@fmease fmease added S-blocked Status: Blocked on something else such as an RFC or other implementation work. needs-rfc This change is large or controversial enough that it should have an RFC accepted before doing it. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 20, 2025
@fmease fmease marked this pull request as draft September 20, 2025 22:42
@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 20, 2025
Copy link
Member

@fmease fmease left a 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.

View changes since this review

@jdonszelmann
Copy link
Contributor

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

@fmease
Copy link
Member

fmease commented Sep 21, 2025

@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.).

@fmease
Copy link
Member

fmease commented Sep 21, 2025

Since this won't be actionable anytime soon, I'll close this PR now. Thanks for your understanding!

@fmease fmease closed this Sep 21, 2025
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 21, 2025
@qxlsz
Copy link
Author

qxlsz commented Sep 21, 2025

Agreed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-meta Area: Issues & PRs about the rust-lang/rust repository itself needs-rfc This change is large or controversial enough that it should have an RFC accepted before doing it. S-blocked Status: Blocked on something else such as an RFC or other implementation work. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants