rls icon indicating copy to clipboard operation
rls copied to clipboard

implementation returns empty list for `clone()`

Open pronvis opened this issue 4 years ago • 0 comments

Hi there! Thanks for project first of all :)

Now, I am wondering why implementation returns empty list for clone() method. And definition returns results for same code.

I use neovim with coc-rls. Don't know how to call the same textDocument/implementation from RLS cli, so can't test it directly, but here is how RLS trace logs looks like from nvim:

[Trace - 12:12:49 PM] Sending request 'textDocument/implementation - (3)'.
Params: {
    "textDocument": {
        "uri": "file:///<file_path>.rs"
    },
    "position": {
        "line": 33,
        "character": 65
    }
}

[Trace - 12:12:49 PM] Received response 'textDocument/implementation - (3)' in 1ms.
Result: []

To reproduce - create new cargo project and add next code to the end of src/main.rs:

pub struct Stub {
    x: i32,
}
impl Iterator for Stub {
    type Item = i32;
    fn next(&mut self) -> Option<Self::Item> {
        let opt_1: Option<i32> = Some(22);
        opt_1.clone();
        unimplemented!()
    }
}

Go to definition for clone() method will jump you to pub trait Clone. Now add

let opt_1: Option<i32> = Some(22);
opt_1.clone();

before type Item = i32; line. Try to go to to definition for clone() method again. Now it jumps to impl Clone for Option.

So, two questions:

  1. why behavior of jump to definition is unstable?
  2. why go to implementation always return not found?

rls version: rls 1.41.0 (b27e117 2020-01-13)

gif

pronvis avatar Mar 20 '20 09:03 pronvis