-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Currently a warning for an unused function returns a span of the entire function. As a consequence, RLS based IDE environments may then put green squiggles on the entire function. This makes it very annoying to work on a function, if you have not yet written the function that uses it.
There may be other unused warnings for structs/traits that could be similarly adjusted.
This issue has been assigned to @Quantumplation via this comment.
scottmcm
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
sanxiyn commentedon Mar 12, 2019
Does it? For me warnings for unused functions only return span of function signatures, not bodies. Is that still annoying? Same for structs.
I think this is somewhat intentional as it is the item that is unused. Spanning the name usually means name resolution failure.
jackmott commentedon Mar 12, 2019
VSCode ends up highlighting the whole function, so if you are correct this bug should be closed and moved to that repo. How can we verify?
sanxiyn commentedon Mar 13, 2019
It would help if you could provide a test case that reproduces the bug, preferably in the following format:
estebank commentedon Aug 6, 2019
Some further details in duplicate #63064
estebank commentedon Oct 18, 2019
Still reproduces.
Quantumplation commentedon Oct 24, 2019
@rustbot claim
I'd like to pick this up as my first contribution. @jakubadamw had said (on the duplicate) that he intended to work on this, but it's been a few months, so I'm not sure if he's lost interest or not.
I started to work on this, and I figured first step would be to write a ui test for it. I notice that by now there's a few
dead-code
related tests. Is there a policy around moving tests to sub folders? If no one objects, I'd like to move all the dead-code related tests to a dead-code subfolder as part of this work as well.jackmott commentedon Oct 24, 2019
@Quantumplation I can't speak for the rust maintainers but generally it is greatly preferred to just have one thing per PR. I would do the test organization as a separate pr.
estebank commentedon Oct 24, 2019
@Quantumplation go for it, in separate commits in the same PR.
jakubadamw commentedon Oct 24, 2019
@Quantumplation, I didn't really lose interest. While investigating a fix I got blocked by #63091. I think you'll hit it too, though maybe you'll come up with a good idea around it.
Quantumplation commentedon Oct 24, 2019
@jakubadamw following @estebank's suggestion in the other issue about using
ident
seems to have circumvented the broken span thing. I'll get a PR up soon in case I'm missing something :) Just gotta wait for these 9207 tests to run... 😛Quantumplation commentedon Oct 24, 2019
@estebank Do you think I should use the ident span for other constructs as well (struct, enum, etc?) Or keep it to just functions?
estebank commentedon Oct 24, 2019
@Quantumplation we should prefer the ident span whenever possible, but be mindful of the output, as there are some cases where pointing at just the ident might be misleading (like when talking about lifetimes or wanting to point at the whole enclosing span). I think almost all cases where we use
def_span(span)
can be replaced with pointing at the ident's span.Quantumplation commentedon Oct 24, 2019
@estebank I'm only going to focus on the dead-code case, and if you think it's worth it, i'll follow up with a more extensive PR where I evaluate other
def_span
cases for replacement. Want to keep my first contribution small :)Rollup merge of rust-lang#65830 - Quantumplation:master, r=davidtwco
Rollup merge of rust-lang#65830 - Quantumplation:master, r=davidtwco