vscode-rust icon indicating copy to clipboard operation
vscode-rust copied to clipboard

no autocomplete for &str argument named `str` in fn

Open zesty opened this issue 4 years ago • 4 comments

fn nothing(str: &str) -> String {
    str.split_w  // no autocomplete
    "foo".spl  // autocomplete works here
}

related? https://github.com/rust-lang/vscode-rust/issues/649

version: v0.7.8 rls rust-analyzer nightly

installed toolchains

stable-x86_64-unknown-linux-gnu (default) nightly-x86_64-unknown-linux-gnu

active toolchain

stable-x86_64-unknown-linux-gnu (default) rustc 1.54.0 (a178d0322 2021-07-26)

5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

zesty avatar Sep 08 '21 10:09 zesty

You shouldn't use both rls and rust-analyzer, and if you want to use the latter, install the standalone extension.

FWIW, your test case works there:

image

lnicola avatar Sep 08 '21 11:09 lnicola

Sorry, wasn't looking too closely when pasting info. Don't think I changed any of that from the default settings:

Rust-client: Engine The underlying LSP server used to provide IDE support for Rust projects. ----> rls

Rust › Rust-analyzer: Release Tag Which binary release to download and use ----> nightly

I think it is not using rust-analyzer; no rust-analyzer in ~/.cargo/bin.

only rust stuff in settings.json:

    "[rust]": {
        "editor.defaultFormatter": "statiolake.vscode-rustfmt",
        "editor.formatOnSave": true
    },
    "rust.cfg_test": true,
    "rust.clippy_preference": "on

zesty avatar Sep 08 '21 13:09 zesty

Appears to be a conflict with recognition of primitives. When I change the arg name to sr, then I get autocomplete. The popup for plain str is just a path:

/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/primitive_docs.rs

Should I chalk this up to "don't name variables after types", even though it appears to work in rust-analyzer per @lnicola?

zesty avatar Sep 09 '21 00:09 zesty

It's a proper bug and it can be fixed, but see https://rust-lang.github.io/rfcs/2912-rust-analyzer.html.

lnicola avatar Sep 09 '21 05:09 lnicola