-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Spans for unused declarations don't need to be whole declaration #33961
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
Comments
To me it feels like we should span either the whole definition or the name but not the “starts” here. I personally prefer showing the full definition still, because most of the time the cause of the error is in-progress work where I have most of the structure prepared in advance but I haven’t implemented the code which would use it. Seeing the variants/fields etc helps me with remembering why the enum/struct is not used yet and exists in the first place and helps deciding whether I should remove it or not. |
We've tried doing the whole declaration before (in fact, I think that was the default in the old error style before the new error work). Trouble is, you end up with a lot of underlined area, which makes errors hard to read, especially if you have a few errors in a row like that. I agree the "starts" here pointer isn't all that helpful here, since it doesn't give your eyes much to go find. |
Do not underline, then? We did not underline multiline spans before and it was fine. Also, oh the opportunity missed with using
Now you could play the sliding game. |
@nagisa - I'm not sure what you're suggesting with "Do not underline, then? We did not underline multiline spans before and it was fine." We played around some with the |> having other meanings but it ends up often being a bit too subtle. For example, I'm unclear on what the multiline span is in your example. Ideally, having something that can be understood "at a glance" seems to be the best general guideline, though that sometimes take a few tries to get to. It sounds like we agree that underlining the name is fine. |
What I’m saying that before we didn’t underline any multi-line spans, only printed it out as is. What I’m trying to say that not underlining the whole definition is fine. |
@nagisa we could potentially carry on with that before. However, it only works if there is exactly one span in the set of spans (and that span is multi-line). I guess we could detect this case, but we still need a policy for the more general case where there are additional spans (e.g., borrowck errors). |
Yeah, I think we always assumed that we'd go and alter a lot of these multi-line spans to just highlight the method name, or some other more-limited case -- basically that multi-line spans would be the exception. |
Similar issue: #35965. |
Point at signature on unused lint ``` warning: struct is never used: `Struct` --> $DIR/unused-warning-point-at-signature.rs:22:1 | 22 | struct Struct { | ^^^^^^^^^^^^^ ``` Fix #33961.
Currently, the spans for unused declarations, like enums and fns, span the whole declaration. Instead of spanning the whole declaration, we now put a single ^ at the beginning to say "it starts here".
But, if you compare unused enums/fns with unused variables an imports, it feels like one is pointing at the beginning and one is pointing at the name:
Shouldn't we instead just underline the name in all cases (assuming there is one)?
Giving us:
The text was updated successfully, but these errors were encountered: