]> git.lizzy.rs Git - rust.git/commit
Merge #5976
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>
Mon, 14 Sep 2020 10:22:20 +0000 (10:22 +0000)
committerGitHub <noreply@github.com>
Mon, 14 Sep 2020 10:22:20 +0000 (10:22 +0000)
commitd134a810377d18e59508c41db839ef440ebde9fe
tree38f92d3234e9ebf23b7762794416fbc5c6d3b0a8
parenta61178d2186b8d9ca324231ab03368819be0ff6e
parent8ebf3596b78dc10541acd7e08d5c857967a9277c
Merge #5976

5976: Complete trait impl immediately after type/const/fn r=jonas-schievink a=oxalica

Currently, we can complete type/const/fn but only if we typed an identifier.
That is, `impl .. { fn f<|> }` has completions with all trait fn including `f`, but `impl .. { fn <|> }` doesn't provide any suggestion (even if explicit trigger it).

This PR tweak the logic of completion match to make it possible.

However, we still need to explicit trigger suggestions (`Control + Space` by default) in vscode to show. Not sure if we can make it automatically triggered after typing the space after `fn`.

Another question is that I cannot figure out why `BLOCK_EXPR` need to be checked. A block expr directly inside a impl block should be invalid, and nested items will failed to locate impl block in specific offset and skip the suggestion. Now I simply removed it and no tests are broken.
https://github.com/rust-analyzer/rust-analyzer/blob/4f91478e50dc5c2a87235e9be8bd91e3f62de4b4/crates/ide/src/completion/complete_trait_impl.rs#L109

Co-authored-by: oxalica <oxalicc@pm.me>