sublimehq / Packages

Syntax highlighting files shipped with Sublime Text and Sublime Merge
https://sublimetext.com
Other
2.94k stars 586 forks source link

[Rust] Inline error reporting can be improved using --message-format short #4004

Open KodrAus opened 3 days ago

KodrAus commented 3 days ago

Expected behavior

rustc and cargo support a --message-format argument that can output errors in a more compact format than the default multi-line human-readable one. Here's an example of how a --message-format short error looks:

src/lib.rs:625:24: error[E0599]: no method named `clockz` found for reference `&Runtime<&dyn ErasedEmitter + Send + Sync, &dyn ErasedFilter + Send + Sync, &..., ..., ...>` in the current scope

This format is nicely compatible with the build system capture group ordering. When matched with a regex:

"file_regex": "^([^:]*):([0-9]*):([0-9]*):\\s*(.*)"

it can report errors in the editor like so:

after

Actual behavior

Compared to the original format, we get a less useful error in the editor, but a more useful error in the build output:

before

I personally prefer the --message-format short version, but I don't think it's universally better if you're not already familiar with Rust to interpret its errors. I thought I'd open up an issue for it just to demonstrate how it could be different and see if that's preferable to anyone else.

Steps to reproduce

  1. Write a Rust program that includes an error
  2. Build using the default Rust plugin and observe the error in the editor
michaelblyons commented 2 days ago

Sounds at least like an interesting build variant. Care to make a PR?

Rust/Rust.sublime-build

(The "real" fix(es) require sublimehq/sublime_text#1430 and sublimehq/sublime_text#938.)

FichteFoll commented 2 days ago

Indeed, it would be acceptible as a variant only but I can see its uses.