rust-lang / rust-lang/rust-analyzer
stale diagnostic after panic
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Very weird - basic code reporting a Syntax error, but it runs fine via Cargo run :)
rust-analyzer version: rust-analyzer version: 0.3.2220-standalone (27e824fad4 2024-12-15) [c:\Users\robertc.vscode\extensions\rust-lang.rust-analyzer-0.3.2220-win32-x64\server\rust-analyzer.exe]
rustc version: rustc 1.83.0 (90b35a623 2024-11-26)
editor or extension: VSCode Version 0.3.2220
relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)
rustup show
$ rustup show
Default host: x86_64-pc-windows-msvc
rustup home: C:\Users\robertc\.rustup
...
installed targets for active toolchain
--------------------------------------
x86_64-pc-windows-msvc
x86_64-unknown-linux-gnu
active toolchain
----------------
stable-x86_64-pc-windows-msvc (default)
rustc 1.83.0 (90b35a623 2024-11-26)
code snippet to reproduce:
use std::collections::HashMap;
use crate::eval::Value;
pub struct Environment {
values: HashMap<String, Value>,
}
impl Environment {
pub fn new() -> Self {
Self {
values: HashMap::new(),
}
}
pub fn define(&mut self, name: String, value: Value) {
self.values.insert(name, value);
}
pub fn get(&self, name: &str) -> Result<Value, Box<dyn std::error::Error>> {
self.values
.get(name)
.cloned()
.ok_or_else(|| format!("Undefined variable {name}").into())
}
}
Reports these problems:
[{
"resource": "/c:/Users/robertc/Documents/src/codecrafters-interpreter-rust/src/environment.rs",
"owner": "_generated_diagnostic_collection_name_#1",
"code": {
"value": "syntax-error",
"target": {
"$mid": 1,
"path": "/stable/reference/",
"scheme": "https",
"authority": "doc.rust-lang.org"
}
},
"severity": 8,
"message": "Syntax Error: expected a block",
"source": "rust-analyzer",
"startLineNumber": 17,
"startColumn": 16,
"endLineNumber": 17,
"endColumn": 16
}]
and
[{
"resource": "/c:/Users/robertc/Documents/src/codecrafters-interpreter-rust/src/environment.rs",
"owner": "_generated_diagnostic_collection_name_#1",
"code": {
"value": "E0308",
"target": {
"$mid": 1,
"path": "/stable/error_codes/E0308.html",
"scheme": "https",
"authority": "doc.rust-lang.org"
}
},
"severity": 8,
"message": "expected String, found &str",
"source": "rust-analyzer",
"startLineNumber": 18,
"startColumn": 28,
"endLineNumber": 18,
"endColumn": 32
}]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the report with the provided src/environment.rs snippet in rust-analyzer and compare its diagnostics with Cargo run. Investigate why the syntax and E0308 diagnostics remain after the reported panic or recovery point. Done means the stale diagnostics no longer appear for this reproduction, with a regression test added if the relevant test location is identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100