racer-rust / racer

Rust Code Completion utility
MIT License
3.36k stars 278 forks source link

racer does not provide complete suggestions for trait and imp #1114

Open stuardcg opened 4 years ago

stuardcg commented 4 years ago

Taking the std::fs::File example I write

use std::fs::File;
use std::io::prelude::Write;
use std::io::ErrorKind;

fn main() {
    let mut f = File::open("story.txt").unwrap_or_else(|err| {
        if err.kind() == ErrorKind::NotFound {
            File::create("story.txt").unwrap()
        } else {
            panic!("{}", err);
        }
    });

    match f.write(b"This is my story") {
        Ok(_) => println!("The story was written."),
        Err(e) => panic!("{}", e),
    }
}

If I go to let mut f = File::open("story.txt").u


$ racer complete 6 41 ./src/main.rs

PREFIX 125,126,u
MATCH unwrap,1002,11,/home/arthaclarius/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/result.rs,Function,pub fn unwrap(self) -> T
MATCH unwrap_err,1064,11,/home/arthaclarius/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/result.rs,Function,pub fn unwrap_err(self) -> E
MATCH unwrap_or,827,11,/home/arthaclarius/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/result.rs,Function,pub fn unwrap_or(self, default: T) -> T
MATCH unwrap_or_default,1102,11,/home/arthaclarius/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/result.rs,Function,pub fn unwrap_or_default(self) -> T
END

If you check the code I can use unwrap_or_else but is not in the complete suggestions.

If I go to match f.w

$ racer complete 14 13 ./src/main.rs

PREFIX 321,322,w
END

But I was expecting write, write_vectored, write_all, and even more.

Maybe I'm wrong but It should be working.