Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Debugging 为什么我会得到;标识符未定义";或;“不可用”;在Visual Studio调试器中检查Rust变量时?_Debugging_Visual Studio Code_Rust - Fatal编程技术网

Debugging 为什么我会得到;标识符未定义";或;“不可用”;在Visual Studio调试器中检查Rust变量时?

Debugging 为什么我会得到;标识符未定义";或;“不可用”;在Visual Studio调试器中检查Rust变量时?,debugging,visual-studio-code,rust,Debugging,Visual Studio Code,Rust,我已经设置了VisualStudio代码调试器并运行以下程序 pub fn main(){ 让mut chars=“test”.chars(); 匹配字符。下一个(){ 一些(c)=>{ println!(“这里c的值是多少?”); 如果c=='c'{ println!(“c”); } } 无=>{} } } 如果我在第6行设置一个断点,并查看变量和观察窗格,c不会计算,而是传递以下消息:标识符“c”未定义,在Windows上使用cppvsdbg,或在Linux上使用lldb。我已经确认,对于

我已经设置了VisualStudio代码调试器并运行以下程序

pub fn main(){
让mut chars=“test”.chars();
匹配字符。下一个(){
一些(c)=>{
println!(“这里c的值是多少?”);
如果c=='c'{
println!(“c”);
}
}
无=>{}
}
}
如果我在第6行设置一个断点,并查看变量和观察窗格,c不会计算,而是传递以下消息:
标识符“c”未定义,在Windows上使用cppvsdbg,或在Linux上使用lldb。我已经确认,对于当前稳定的编译器版本,这种情况在Linux和Windows版本上都会发生

我还在Cargo.toml中添加了以下内容,但没有效果:

[profile.dev]
opt-level = 0
debug = true
以下是VS代码编译器所需的launch.json文件供参考:

{
    "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
        }
    ]
}
用您选择的操作系统替换“(Windows)启动”


为什么会有这样的结果?是否有修复程序,或者是否应该添加一些编译器选项?

LLDB还不支持许多生锈的概念。它不能理解枚举,显然也不能理解字符。
rust gdb
能够打印值:
$rust gdb target/debug/pr
,然后
(gdb)br main.rs:6
(gdb)运行
,当它停止时
(gdb)print c
显示:
$1=116't'
。可能相关:我现在不一定能够深入研究这个问题,但这也可能相关:与您的直接问题正交,但是在这段代码中,
if let
match
更惯用。