Debugging Rust on Windows using Visual Studio Code


如果没有visual Studio的话,要下载Visual Studio Build Tool 2015

其次,启动VS Code,安装Extension

  1. ext install C++ -- 安装C++(Windows)
  2. ext install Debug -- 安装GDB,llDB
  3. ext install vscode-rust



rustup self update

rustup update nightly

rustup component add rls --toolchain nightly

rustup component add rust-analysis --toolchain nightly

rustup component add rust-src --toolchain nightly

rustup component add rust-src --toolchain stable



set RUST_SRC_PATH=%USERPROFILE%\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\src\rust\src


set RUST_SRC_PATH=%USERPROFILE%\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src


cargo install racer
cargo install rustfmt
cargo install rustsym


WASM编译: 安装

rustup target add wasm32-unknown-emscripten nightly

在VS Code中点击选择“Add Configuration", 这回自动在 .vscode目录下生成一个Launch.json。进行相应的修改,于本地环境相配。

    "version": "0.2.0",
    "configurations": [
            "name": "(Windows) Launch",

            "type": "cppvsdbg",
            "request": "launch",
            "program": "${workspaceRoot}/target/debug/hello_world.exe",
            "symbolSearchPath": "C:\\Symbols",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": true,
            "sourceFileMap": {


Cargo Build


我的 vscode 配置:

    "evermonkey.token": "S=s2:U=108b6a9:E=166c8b45e40:C=15f71032f38:P=1cd:A=en-devtoken:V=2:H=e5205536fccf0804da1726ce1eaae864",
    "evermonkey.noteStoreUrl": "",
    "files.eol": "\n",
    "[markdown]": {
        "editor.quickSuggestions": true
    "workbench.colorTheme": "Agila Light Solarized",
    "liveServer.settings.donotShowInfoMsg": true,

    // rust
    "debug.allowBreakpointsEverywhere": true,
    "": "C:\\WINDOWS\\System32\\cmd.exe",
    "rust.rustup": {
        "toolchain": "nightly-x86_64-pc-windows-msvc",
        "nightlyToolchain": "nightly-x86_64-pc-windows-msvc"
    "rust.mode": "rls",
    "rust.rls": {
        "useRustfmt": true
    "": "nightly",
    // go
    // Go configuration
    // Run 'go build'/'go test -c' on save.
    "go.buildOnSave": true,
    // Flags to `go build`/`go test` used during build-on-save or running tests. (e.g. ['-ldflags="-s"'])
    "go.buildFlags": [],
    // Run Lint tool on save.
    "go.lintOnSave": true,
    // Specifies Lint tool name.
    "go.lintTool": "golint",
    // Flags to pass to Lint tool (e.g. ['-min_confidenc=.8'])
    "go.lintFlags": [],
    // Run 'go tool vet' on save.
    "go.vetOnSave": true,
    // Flags to pass to `go tool vet` (e.g. ['-all', '-shadow'])
    "go.vetFlags": [],
    // Pick 'gofmt', 'goimports' or 'goreturns' to run on format.
    "go.formatTool": "goreturns",
    // Flags to pass to format tool (e.g. ['-s'])
    "go.formatFlags": [],
    // Run the formatting tools with the -d flag
    "go.useDiffForFormatting": true,
    // Complete functions with their parameter signature
    "go.useCodeSnippetsOnFunctionSuggest": false,
    // Specifies the GOPATH to use when no environment variable is set.
    "go.gopath": "E:/gocode",
    // Specifies the GOROOT to use when no environment variable is set.
    "go.goroot": "D:/go",
    // Run formatting tool on save.
    "go.formatOnSave": true,
    // Run 'go test -coverprofile' on save
    "go.coverOnSave": false,
    // Specifies the timeout for go test in ParseDuration format.
    "go.testTimeout": "30s",
    // Enable gocode's autobuild feature
    "go.gocodeAutoBuild": true,
    // The Go build tags to use for all commands that support a `-tags '...'` argument
    "go.buildTags": "",
    // Environment variables that will passed to the process that runs the Go tests
    "go.testEnvVars": {},
    // Autocomplete members from unimported packages.
    "go.autocompleteUnimportedPackages": true,
    "git.ignoreMissingGitWarning": true,
    "extensions.ignoreRecommendations": false,
    "workbench.iconTheme": "material-icon-theme",
    "explorer.openEditors.visible": 20