rust analyzer reports only syntax error.
I am using latest rustc 1.61.0 and the latest rust-analyzer on macOS 12, when I open an rs file by helix-editor, it will only report syntax error as the picture shows. And if there are no syntax errors, no errors are reported. When I open the file, the red errors signs in line 2 and line 3 appear for 1 second and then disappear. See the video below
https://user-images.githubusercontent.com/52552971/173172117-b40cbc78-bcda-4171-b18d-64317eaa7c69.mov
.
the same is for vscode

For vscode you didn't save the file. cargo check only runs when you save a file as it can only read files from the disk and not from the memory of your editor.
For vscode you didn't save the file.
cargo checkonly runs when you save a file as it can only read files from the disk and not from the memory of your editor.
is there a way to use the check without saving? I find the rust official extension in vscode can do such thing.
Some things are already checked:

I set
"editor.semanticTokenColorCustomizations": {
"rules": {
"unresolvedReference": "#ff0000",
},
}
for the red variable and enabled rust-analyzer.diagnostics.experimental.enable for the type mismatch. But both have some false-positives.
We already have https://github.com/rust-lang/rust-analyzer/issues/3107 as a tracking issue for live diagnostics, but it's very long-term.
I find the rust official extension in vscode can do such thing.
The extension you're referring to is now deprecated, and has been unmaintained for a while.