rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.21k stars 1.6k forks source link

Don't enable problem matchers for tasks when checkonsave is enabled. #4768

Closed mehmooda closed 4 years ago

mehmooda commented 4 years ago

VSCode will show the same problem twice. 1) Last time file was saved 2) Last time a task was run (Run Test inline button)

If you make an edit and save; the old problems from when the last time a task was run are not updated. Which leaves behind stale problems (possibly on wrong line numbers)

Proposed fix:

Don't run the rustc problemmatcher for tasks if check on save is enabled. I don't think it's possible for run task to give different problems to what the check on save will find anyway and this should fix the problems window showing stale problems.

bjorn3 commented 4 years ago

I don't think it's possible for run task to give different problems to what the check on save will find anyway

It is possible. There are so called monomorphization errors that only get emitted when doing a full compile and not a check build. For example:

#![feature(asm)]

pub fn a() {
    unsafe { asm!("abc"); }
}
mod a {
    #[no_mangle]
    pub static A: u8 = 1;
}

mod b {
    #[no_mangle]
    pub static A: u16 = 2;
}

fn main() {
    println!("{}", a::A as u16 + b::A);
}

and a lot of cases where intrinsics are misused.

mehmooda commented 4 years ago

I guess the correct fix would be to dedupe and remove the problems from the task list which are already in the checkonsave list. This should hopefully be possible as running a task, should also causes a checkonsave and they should both run with the same file tree. I'm not familiar with the vscode extension API so I'm not sure if this is possible.

This would still leave some stale problems, but at least they are the problems which check can't find. And running another task (build, test) would clear that list.

Until then any chance of a disable task problem matcher config option, for crates which mere mortals will write.

matklad commented 4 years ago

I don't think we can dynamically reonfigure problem matchers.

I'd say the problem should be fixed in VS Code -- it should clear diagnostisc from tasks or at least shift the ranges.

matklad commented 4 years ago

(a work-around I use personally is disabling checkOnSave :-) )