I've set up the Visual Studio Code debugger and run the following program.

pub fn main() {
    let mut chars = "test".chars();
    match chars.next() {
        Some(c) => {
            println!("What is the value of c, here?");
            if c == 'c' {
        None => {}

If I set a breakpoint at line 6, and look in the Variables and Watch panes, c does not evaluate, but rather passes the following message: identifier 'c' is undefined using cppvsdbg on Windows, or <not available> using lldb on Linux. I've confirmed that this happens both on Linux and Windows builds, for the current stable compiler version.

I've also added the following to Cargo.toml to no avail:

opt-level = 0
debug = true

For reference, here is my launch.json file, needed for the VS Code compiler:

    "version": "0.2.0",
    "configurations": [
            "name": "(Windows) Launch",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${workspaceFolder}/target/debug/test.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true

Replace "(Windows) Launch" with your OS of choice.

Why is this the result? Is there a fix, or are there some compiler options that should be added?



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.