-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Add "related spans" to diagnostic messages #10489
Comments
One thing I want is for quick-fixes to operate on related spans as well. For instance, if we fixed #10464, where we'd look for a namespace with the same text as an import path, we would have a related span for the namespace declaration. I'd imagine a quick fix on the namespace declaration for the actual fix. |
this is definitely doable.
do you have an experience in mind? can you elaborate? how does it look on the command line? do you reference the original declaration all the time? only some types?
this sounds intriguing. specially with VSCode support to click on file names and jump to the location. coupled with some colors this would be a great productivity boost. |
@mhegazy Something along the lines of (to extended on one of the examples from #5140):
Inside vscode, the extended information blocks ( |
Looking for more examples of errors where this would be useful, plus how we would display them on the commandline (or editor) in a useful way |
A better, richer way to display the same information #19356 added, for one thing. |
We have these now, and have had them for awhile. 😉 |
We already have
--pretty
error message output, but we can do even better. In this blog post @jonathandturner describes a set of improvements to Rust's error message framework to allow for an error to specify related spans, other than the primary span where the error was encountered - and to provide extra elaboration on each of those spans. This is incredibly useful, and we can do the same.For example, when we report a duplicate definition error, in the diagnostic object, we could return the spans for the secondary declaration locations in the diagnostics object (potentially with elaboration on how they are a duplicate hidden behind a
--elaborate
flag). Missing member errors can have a reference back to the type definition (since the error is equally likely to be fixed there). Type errors on assignments can reference back to the declaration of the LHS. There's probably countless errors where we could refer to a secondary location where either a type is likely wrong and causing the error or where the error is likely to be fixed. On the command line, this can just be surfaced as part of the currentpretty
output, and inside vscode we could potentially coordinate to cause additional related spans to cause a code window to appear in the details popover.The text was updated successfully, but these errors were encountered: