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

Completion based on trait bounds #939

Open
10 of 14 tasks
kngwyu opened this issue Aug 30, 2018 · 5 comments
Open
10 of 14 tasks

Completion based on trait bounds #939

kngwyu opened this issue Aug 30, 2018 · 5 comments

Comments

@kngwyu
Copy link
Collaborator

kngwyu commented Aug 30, 2018

Related: #706, #829

General roadmap

fn f<T: Clone>(a: T) {
    let b = a.clo~
}
struct S<T> {
    mem: T
}
fn f<T: Clone>(a: S<T>) {
    let b = a.mem.clo~
}
impl<T: Clone> S<T> {
    fn f(self) {
        let b = a.mem.clo~
    } 
}
  • for closures
fn fun<F: Fn() -> Option<i64>>(f: F) {
    let a = f().unwra~
}

Precise roadmaps

refactor generics support

  • Intoroduce ImplHeader Intoroduce 'ImplHeader' #938
  • Replace MatchType::Impl and MatchType::TraitImpl with ImplHeader
  • Remove Match::generics_args and Match::generic_types
  • Modify MatchType::Enum and etc to have generics
  • Intoroduce MatchType::Method which has ImplHeader
    - [ ] Remove PathSearch TOO HARD
  • Refactor TraitBounds again
    - [ ] Use GenericsArgs to resolve type params, instead of taking Match Now I think there's no use

enhance scope_start's inefficiency

  • Have scope cache

Method search

  • rewrite method search using ImplHeader

TypeName resolution

  • resolve type parameter in ImplHeader when resolve_path is called

Related issues

@letmutx
Copy link
Contributor

letmutx commented Oct 16, 2018

Hi! Is struct member method completions working? I can't seem to get completions with the latest master. I am using the same example above

struct S<T> {
    mem: T
}
fn f<T: Clone>(a: S<T>) {
    let b = a.mem.clo~
}
$ RUST_LOG=racer=trace ../racer/target/debug/racer complete 5 21 src/main.rs 2> trace.txt
PREFIX 71,74,clo
END

trace.txt

Weirdly enough, the testcases in tests/trait_bounds.rs pass.

@kngwyu
Copy link
Collaborator Author

kngwyu commented Oct 17, 2018

Thanks.

Weirdly enough, the testcases in tests/trait_bounds.rs pass.

Tests contain only 'bounded by impl' cases, like

impl<T: Clone> S<T> {
    fn f(self) {
        let b = a.mem.clo~
    } 
}

, so it's not weird.
I don't remember it's simply not implemented or broken, but anyway fix it later.

@letmutx
Copy link
Contributor

letmutx commented Oct 17, 2018 via email

@kngwyu
Copy link
Collaborator Author

kngwyu commented Oct 17, 2018

@letmutx
Thanks, but I want to fix this by myself, to recall what I implemented in last month.

@letmutx
Copy link
Contributor

letmutx commented Oct 17, 2018

@kngwyu Okay. I have some progress here: https://github.com/letmutx/racer/tree/add-struct-member-trait-completions

@kngwyu kngwyu mentioned this issue Oct 23, 2018
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants