racer icon indicating copy to clipboard operation
racer copied to clipboard

Completion based on trait bounds

Open kngwyu opened this issue 5 years ago • 5 comments

Related: #706, #829

General roadmap

  • [x] for FnArg already implemented in #828, #937
fn f<T: Clone>(a: T) {
    let b = a.clo~
}
  • [x] for struct member implemented in #948 , #975
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~
}
  • [x] associated functions and types implemented in #991

Precise roadmaps

refactor generics support

  • [x] Intoroduce ImplHeader #938
  • [x] Replace MatchType::Impl and MatchType::TraitImpl with ImplHeader
  • [x] Remove Match::generics_args and Match::generic_types
  • [x] Modify MatchType::Enum and etc to have generics
  • [x] 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

  • [x] rewrite method search using ImplHeader

TypeName resolution

  • [x] resolve type parameter in ImplHeader when resolve_path is called

Related issues

  • [ ] Generic type with multiple type parameter(#900) I think this will be easily fixed after refactoring all codes.

kngwyu avatar Aug 30 '18 10:08 kngwyu

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.

letmutx avatar Oct 16 '18 21:10 letmutx

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.

kngwyu avatar Oct 17 '18 01:10 kngwyu

Right. I was obviously overlooking that. Sorry. I would like to take a go at this.

On Wed, Oct 17, 2018 at 7:29 AM Yuji Kanagawa [email protected] wrote:

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.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/racer-rust/racer/issues/939#issuecomment-430462432, or mute the thread https://github.com/notifications/unsubscribe-auth/AZcHBLvVtSfCCmh02uQ5gALD8sQAYbcvks5ulo8bgaJpZM4WTPiI .

letmutx avatar Oct 17 '18 07:10 letmutx

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

kngwyu avatar Oct 17 '18 07:10 kngwyu

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

letmutx avatar Oct 17 '18 08:10 letmutx