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

Corrected impl lookup to search whole scope and fixed a bug with tuple/unit structs at end of scope #570

Merged
merged 2 commits into from
Jul 11, 2016

Conversation

Jonesey13
Copy link
Contributor

This PR fixes two issues. Firstly there is an issue where racer could panic when completing on a tuple or unit struct at the end of a scope:

mod sub {
    impl Foo {
        pub fn two(&self) -> usize {2} 
    }
    pub struct Foo(bool);
}

fn main() { // l16
    let t = sub::Foo(true);
    t.t
}

Originally, if one tried to complete on t.t, racer would panic since it would try to find fields on the struct Foo, look ahead for an open/close brace and panic when it meets the } at the end of the Sub module. This is because of an u32 underflow in scopes::find_close which has now been fixed.

Secondly, the completion at t.t above would still fail since racer would start searching for implementations from the F in pub struct Foo(bool) rather than from the start of the module scope. This has now been fixed and a new test has been added to cover this case.

@phildawes phildawes merged commit 65a6b5f into racer-rust:master Jul 11, 2016
@phildawes
Copy link
Collaborator

This is great, thanks @Jonesey13

@Jonesey13 Jonesey13 deleted the late_struct_declare_fixes branch July 24, 2016 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants