rust-lang / rust-lang/rust-analyzer
Invalid completion for function parameters of cfg'd functions
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)
rust-analyzer 1.80.0 (05147895 2024-07-21)
rustc version: (eg. output of rustc -V)
rustc 1.80.0 (051478957 2024-07-21)
editor or extension: (eg. VSCode, Vim, Emacs, etc. For VSCode users, specify your extension version; for users of other editors, provide the distribution if applicable)
Helix 24.7 (dbaa6366)
relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)
None I believe
repository link (if public, optional): (eg. rust-analyzer)
N/A
code snippet to reproduce:
Insert the following code into a module that does not have Path currently imported in the namespace. The return parameter can be any type that has a type parameter.
#[cfg(windows)]
pub fn test_case() -> Option<Path> {
}
While typing the Path parameter, select the completion for inserting a use statement
The result:
This one showed up for the first time while creating this issue. I tried recreating it a few times and was unsuccessful.
This is what usually happens
Both are invalid, the use statement is not visible for the return parameter of the cfg'd out function.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied Rust reproducer in a module lacking the Path import, then inspect the completion behavior while editing the return type of the cfg'd function. Verify both the usual and intermittent completion results; done means selecting the import completion produces a valid use statement visible for the function's return parameter.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100