A task provider for rust tasks that uses a custom problem matcher to provide additional information, quick-fix solutions and refactorings for warnings and compile errors.
- Includes quick-fixes for problems even if the fixes aren't guaranteed to be correct
- The problem view will include
help
attachments - The problem view will include
note
attachments - The problem view will include additional spans as attachments
rust-problem will inject a custom refactoring suggestion based on your current selection. This allows you to apply multiple problem suggestions at once.
Some problems will be marked as preferred, which makes them work with vscode's auto fix. The default shortcut is shift + alt + .
, but you can overwrite it with something like this, then all you have to do is to place your cursor at the problem and hit alt+f
.
{
"key": "alt+f",
"command": "editor.action.autoFix",
"when": "editorTextFocus && !editorReadonly && supportedCodeAction =~ /(\\s|^)quickfix\\b/",
"args": {
"apply": "first"
}
},
- Download the latest release from our releases
- Open vscode and press
ctrl + shift + p
to open the command palette - Seach for and run
Extensions: Install from VSIX
- Select the downloaded extension
- All done!
- Open vscode and press
ctrl + shift + p
to open the command palette - Search for
Tasks: Run Task
- Move the cursor to the
rust-problem
collection, hit enter - Pick your task and run it!
- Upen up the problems view to see the encountered warnings and errors (
ctrl + shift + m
) - You can view the raw output in a terminal tab
When using rust-analyzer
and their provided pattern matchers, some information is unforunately lost in the void. For example, the notes
, help
and additonal spans
are erased and you end up with only the top-level message in your problems view. Another issue with r-a
is that some quick-fixes aren't suggested, such as automatically inserting missing lifetimes.
For example, running cargo check with r-a
on this code:
struct MissingLifetime {
foo: &str,
}
The error view receives this information:
{
"resource": "/home/rasviitanen/GitHub/MdMap/src/list.rs",
"owner": "rustc",
"code": "E0106",
"severity": 8,
"message": "missing lifetime specifier",
"source": "rustc",
"startLineNumber": 67,
"startColumn": 10,
"endLineNumber": 67,
"endColumn": 10
}
But with Rust Problems
we can squeeze in some extra information:
{
"resource": "/home/rasviitanen/GitHub/MdMap/src/list.rs",
"owner": "rustProblems",
"code": "E0106",
"severity": 8,
"message": "missing lifetime specifier",
"startLineNumber": 67,
"startColumn": 10,
"endLineNumber": 67,
"endColumn": 11,
"relatedInformation": [
{
"startLineNumber": 67,
"startColumn": 11,
"endLineNumber": 67,
"endColumn": 11,
"message": "HELP: consider introducing a named lifetime parameter",
"resource": "/home/rasviitanen/GitHub/MdMap/src/list.rs"
},
{
"startLineNumber": 67,
"startColumn": 10,
"endLineNumber": 67,
"endColumn": 11,
"message": "SPAN: expected named lifetime parameter",
"resource": "/home/rasviitanen/GitHub/MdMap/src/list.rs"
}
]
}
And also add a quick-fix to replace this with:
struct MissingLifetime<'a> {
foo: &'a str,
}