-
Notifications
You must be signed in to change notification settings - Fork 1.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
Scope prints in diagnostics #2777
Conversation
b8ce648
to
a3b6de6
Compare
We can already do the following:
but it needs to be done on every error manually. Although this approach requires more effort, it also is more targeted, which means that we only show it when relevant. The devil's in the details, but the implementation of this seems "hard". |
@estebank yeah, it's hard. There's also the issue of avoiding redundant scope prints when we have two or more different types of errors in the same scope [1], which probably means tracking scopes and perform unification of several unrelated errors based on their scope. Perhaps this can be done outside the call sites to emit diagnostics (i.e. only in On the bright side, simply avoiding duplicates in [1]
[2]
|
cc @rust-lang/wg-diagnostics |
I realize this RFC is quite old at this point but in case anyone is interested in this, I agree with @estebank's comment. If there are specific errors where this context would be helpful, I think we would be willing to just review PRs that target those specific errors. For more general or wide ranging changes, I think it would be best to open an MCP to discuss those changes. |
I'm going to close this RFC in favor of more targeted MCPs for specific error types. |
Summary
The proposed change is to add context information in warnings and errors, so that not only source positions are printed, but also item names. For example,
in fn main
, orin fn mod::function
, orin struct Foo
. Also, relevant lines in annotation are added (but not repetitively).Instead of:
Related links