grace
grace copied to clipboard
Supporting notes wil labels
Rust compiler messages can contain suggestions like in the following diagnostic.
error[E0382]: borrow of moved value: `x`
--> src/main.rs:5:15
|
2 | let x = String::from("Hello, world!");
| - move occurs because `x` has type `String`, which does not implement the `Copy` trait
3 | drop(x);
| - value moved here
4 |
5 | println!("{x}");
| ^^^ value borrowed here after move
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
|
3 | drop(x.clone());
| ++++++++
For more information about this error, try `rustc --explain E0382`.
I don't think it is possible to do the same with grace at the moment (we have notes but it does not take any label). The best I can come up with is to have two diagnostics. Is this what is intended? The diagnostic may contain some redundancy in that case.
It is currently not possible to (easily) do the same with Grace.
Adding Label.t for notes doesn't necessarily give you a nice API for achieving the error message in your example since we'd have to nicely render diffs as well.
We can easily change the type to render labels for notes. Rendering diffs might be harder to achieve