Search code examples
visual-studio-coderustrust-cargorust-analyzer

vscode does not work when it has multiple cargo projects?


I'm learning to use rust,i am using vscode。 I have two cargo projects in my workspace,Why rust-analyzer only has an error message in the first project, but not in the second。 enter image description here

enter image description here

Is there any setting required?


Solution

  • You need to create workspace:

    • Create Cargo.toml in your root project
    • Add this code:
    [workspace]
    members = [
        "./<your-cargo-project1>",
        "./<your-cargo-project2>",
    
    
    ]