rust-fuzz / cargo-fuzz

Command line helpers for fuzzing
https://rust-fuzz.github.io/book/cargo-fuzz.html
Apache License 2.0
1.48k stars 108 forks source link

Vscode / Visual Studio tips for Rust Analyzer with cargo fuzz #352

Open cameronelliott opened 6 months ago

cameronelliott commented 6 months ago

Hey, thanks contributors for making and maintaining this awesome project!

I had an issue with vscode where editing files inside ProjectZ/fuzz/fuzz_targets/targetX.rs wasn't working with or providing me any Rust Analyzer feedback. At least when I would open the ProjectZ folder inside vscode. I would get Rust Analyzer support when opening the fuzz folder, but that seemed to me as a less than ideal workaround. I wanted to open the ProjectZ folder and work on both my project and my fuzz_targets.

It turns out there is a solution by editing this into the end of my vscode settings.json, I get Rust Analyzer support for both my parent project, and inside the fuzz/fuzz_targets folder.

    "rust-analyzer.linkedProjects": [
        "Cargo.toml",
        "fuzz/Cargo.toml"
    ]
}

At the moment I have that in my vscode user settings, and from a quick test, that global setting seems to work fine with Rust projects without a fuzz folder. You might want to put it in your vscode workspace settings if you want to control this on a project by project basis.

cameronelliott commented 6 months ago

I wrote this to help future users. It can be closed. I will file a report at the book in case it should be added there.