Skip to content
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

Allow impl item from anywhere #630

Merged
merged 4 commits into from
Sep 14, 2023
Merged

Allow impl item from anywhere #630

merged 4 commits into from
Sep 14, 2023

Conversation

udoprog
Copy link
Collaborator

@udoprog udoprog commented Sep 14, 2023

Like the title says, support adding an impl <type> block anywhere and have it being handled correctly.

Like:

struct Foo;

pub fn main() {
    let value = {
        impl Foo {
            fn lol(self) {
                4
            }
        }
    };

    assert_eq!(Foo.lol(), 4);
}

This required the introduction of an intermediary step during indexing. We collect all impl blocks, and once the indexing queue is empty we start processing them. This ensures that imports are visible to the impl blocks and any other items (local or otherwise) which might affect the impl target. Luckily anything inside of the impl block itself can never be used as a target.

@udoprog udoprog added the enhancement New feature or request label Sep 14, 2023
@udoprog udoprog enabled auto-merge (squash) September 14, 2023 16:30
@udoprog udoprog merged commit e98eaca into main Sep 14, 2023
16 checks passed
@udoprog udoprog deleted the impl-item-anywhere branch September 14, 2023 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant