Questions tagged [rust-analyzer]

100 questions
81
votes
9 answers

rust-analyzer failed to discover workspace in vscode

I'm starting to learn the Rust language and I have an issue with rust-analyzer vscode extension. It doesn't provide code completion as shown in the link: https://rust-analyzer.github.io/manual.html#magic-completions Vscode shows notification as…
wowonline
  • 1,061
  • 1
  • 10
  • 17
41
votes
2 answers

How can I remove type annotation help when using rust-analyzer?

For VS Code, I use rust-analyzer to handle syntax highlighting and flychecking. How do I remove the inlay type and parameter annotations in grey below?
Thorkil Værge
  • 2,727
  • 5
  • 32
  • 48
21
votes
3 answers

What does the rust-analyzer error "could not resolve macro `$crate::format_args`" mean and how do I fix it?

I'm using rust-analyzer version 0.2.408 on Visual Studio Code. I'm writing a command line application that involves centering text in the terminal. This is the function I wrote to do this: use console::{Alignment, pad_str}; fn get_padded_row(row:…
Denendaden
  • 213
  • 2
  • 7
14
votes
2 answers

How to enable real-time linting while typing with rust-analyzer in VSCode?

I have rust-analyzer extension in VSCode. In settings I only changed Rust-analyzer › Check On Save: Command from check to clippy (this shouldn't matter). Problem is I don't see errors when I type, only after I save. Typed (no error): Saved (can see…
ZiiMakc
  • 31,187
  • 24
  • 65
  • 105
12
votes
2 answers

Error: proc macro `main` not expanded: Cannot create expander for

I want to run a web server with Rust and Actix-Web. After following these steps of their documentation everything works as expected: the server runs on port 8080. The problem I have is that VSCode shows errors This error message is shown in the…
Roman Mahotskyi
  • 4,576
  • 5
  • 35
  • 68
8
votes
2 answers

How to get type hints to display?

I have seen youtubers and such working on Rust in VSC with rust-analyzer plug-in where they get the optional type annotations displayed, even if it isn't necessarily written in the code. It's like I type foo(a,b) in the editor and it automagically…
jsstuball
  • 4,104
  • 7
  • 33
  • 63
7
votes
1 answer

Find symbol by name including dependencies in VSCode

In IntelliJ IDEA when I press Ctrl+Shift+Alt+N, I can search and go to any symbol from all the code that is accessible within the project. For example, in a Java Maven project, Go To Symbol would search all symbols across the JDK standard library,…
Yuri Geinish
  • 16,744
  • 6
  • 38
  • 40
6
votes
1 answer

rust-analyzer in VSCode does not work in rustlings workspace

I'm going through the rustlings exercises, and noticed that rust-analyzer was on but was not generating any inline error messages or type hints. Basically not doing anything at all. I thought this was because I didn't open the top-level rustlings…
xdavidliu
  • 2,411
  • 14
  • 33
5
votes
1 answer

Is there a way to stop rust-analyzer from dimming "inactive" code?

I am currently making an embedded system. For that I have 2 different panic handlers based on whether it is run normally or as a test. #[cfg(test)] for the test panic handler and #[cfg(not(test))] for the normal panic handler. rust-analyzer says:…
lv4
  • 53
  • 6
4
votes
2 answers

Auto completion not working for rust in module files (vs code)

In my main.rs I get code completion just fine. But I don't get it in my module files. My folder structure looks like this: src/ |___game_components/ | |___card.rs |___game_components.rs |___main.rs The program builds and runs just fine (aside…
4
votes
5 answers

Rust-analyzer failed to load workspace vscode

I know that there are a lot of similar questions regarding rust-analyzer and I've checked them out but couldn't find the solution to my problem so I decided to ask a question myself. I've decided to start learning Rust and I'm having issues with…
kosingas
  • 61
  • 1
  • 7
4
votes
2 answers

rust-analyzer.linkedProjects doesn't work with relative path, ${workspaceFolder}. Is there any workaround?

I have a repository that has a Cargo.toml in sub_dir/Cargo.toml (Cargo.toml is not in repository root directory) I'm using the repository from some of my computers. So I need to set up rust-analyzer.linkedProjects by each environment... I want to…
tomlla
  • 519
  • 1
  • 6
  • 15
4
votes
0 answers

Rust-analyzer throws "unresolved-macro" despite disabling "macro-error" and "unresolved-macro-call"

I'm writing some backend code in rust using VSCode and of course the rust-analyzer. As many others, I have gotten issues with linting of macros by rust-anylyzer. I tried suppressing the linting/errors in settings.json, but with very little success. …
Philipp Doerner
  • 1,090
  • 7
  • 24
4
votes
1 answer

rust-analyzer: Failed to write request: Broken pipe (os error 32)

Got this error with rust-analyzer VS Code, although cargo build builds the project without errors or warnings. rustc version: 1.54.0 I would like to stay on the "stable" rustc version and not shift to "nightly".
Thorkil Værge
  • 2,727
  • 5
  • 32
  • 48
4
votes
1 answer

What is an underscore in rust-analyzer's type hints for array size?

I am a Rust beginner, please bear with me. As you can see in the image below, VS Code rust-analyzer prompts a type hint with an underscore "_" in the size part. What is it? let a: [i32; _] = [3; 5]; // this is the same as let a: [i32; _] = [3, 3, 3,…
shin
  • 31,901
  • 69
  • 184
  • 271
1
2 3 4 5 6 7