VSCode problem when cargo.toml is in subfolder

VSCode stops highlighting problems in code after first build.

I have created a standard Tauri project. It means the root of the project, where .git and .vscode dirs are, contains dir src-tauri, which contains cargo.toml and a dir src, which contains main.rs. That is how all Tauri documentation and its new project cookiecutter make projects.

When I open it in VSCode, all works fine. However, as soon as I press F5 to run, things break. Cargo builds and runs the app just fine. But VSCode stops highlighting problems and errors in code. I also can no more click on the entry in "problems", it leads to an empty file now.
This is because cargo, when building, reports errors with path src/main.rs while in fact, and as VSCode sees it, the path is ./src-tauri/src/main.rs VSCode seems to prefer cargo report to its own analyzis.

Here is the relevant part of launch.json. The commented lines are options I tried, and if I remove the manifest path, cargo reports cargo.toml not found. Isn't cargo supposed to search cargo.toml in child folders?

{
            "type": "lldb",
            "request": "launch",
            "name": "Tauri Development Debug",
            "cargo": {
              "args": [
                "build",
                "--manifest-path=./src-tauri/Cargo.toml",
              ]
            },
            // "cwd": "${workspaceFolder}/src-tauri",
            // "relativePathBase": "${workspaceFolder}/src-tauri",
          },

In your settings, do:

"rust-analyzer.linkedProjects": ["./src-tauri/Cargo.toml"]

See User Manual

Thanks! But it did not help. Nothing changed.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.