Skip to content

fix: in VSCode, correctly resolve relative paths to errors #13367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 10, 2022

Conversation

matklad
Copy link
Member

@matklad matklad commented Oct 8, 2022

VS Code problem matcher are restricted to be static "regexes". You can't create a problem matcher dynamically, and you can't use custom code in lieu of problem matcher.

This creates a problem for rust/cargo compiler errors. They use paths relative to the root of the Cargo workspace, but VS Code doesn't necessary know where that root is.

Luckily, there's a way out: our current problem matcher is defined like this:

"fileLocation": [ "autoDetect", "${workspaceRoot}" ],

That means that relative pahts would be resoleved relative to workspace root. VS Code allows to specify a command inside ${}. So we can plug custom logic there to fetch Cargo's workspace root!

And that's exactly what this PR is doing!

VS Code problem matcher are restricted to be static "regexes". You can't
create a problem matcher dynamically, and you can't use custom code in
lieu of problem matcher.

This creates a problem for rust/cargo compiler errors. They use paths
relative to the root of the Cargo workspace, but VS Code doesn't
necessary know where that root is.

Luckily, there's a way out: our current problem matcher is defined like
this:

    "fileLocation": [ "autoDetect", "${workspaceRoot}" ],

That means that relative pahts would be resoleved relative to workspace
root. VS Code allows to specify a command inside `${}`. So we can plug
custom logic there to fetch Cargo's workspace root!

And that's exactly what this PR is doing!
@Veykril
Copy link
Member

Veykril commented Oct 10, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Oct 10, 2022

📌 Commit 5bbfea0 has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Oct 10, 2022

⌛ Testing commit 5bbfea0 with merge 79a3f84...

@bors
Copy link
Contributor

bors commented Oct 10, 2022

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing 79a3f84 to master...

@bors bors merged commit 79a3f84 into rust-lang:master Oct 10, 2022
@matklad matklad deleted the fix-problem-matchers branch October 10, 2022 08:10
bors added a commit that referenced this pull request Oct 14, 2022
…=jonas-schievink

Revert "fix: in VSCode, correctly resolve relative paths to errors"

Reverts #13367

I didn't manage to figure out what exactly is the issue, so reverting this to fix #13404 before monday.
@Sytten
Copy link

Sytten commented Oct 14, 2022

@matklad The PR was reverted FYI because it broke the test button

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants