Iterate over maybe_unused_trait_imports when checking dead trait imports#97609
Iterate over maybe_unused_trait_imports when checking dead trait imports#97609bors merged 1 commit intorust-lang:masterfrom Elliot-Roberts:unused-trait-refactor
maybe_unused_trait_imports when checking dead trait imports#97609Conversation
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @cjgillot (or someone else) soon. Please see the contribution instructions for more information. |
cjgillot
left a comment
There was a problem hiding this comment.
Thanks @Elliot-Roberts! This looks very good. I left a few comments.
There was a problem hiding this comment.
I guess that the point of this check is to avoid reporting for use items that are injected by macros or the compiler. You can leave it as-is, it's very fast.
There was a problem hiding this comment.
Could I add a test with a macro that injects an unused trait use? I'm not sure how to check the compiler-injected ones though.
There was a problem hiding this comment.
You'd need to write a proc macro for this. The proc macro would have to create a use Stuff; item, where the use and ; have a dummy span, and Stuff has a real one from the macro's input code.
There was a problem hiding this comment.
@Elliot-Roberts crafting the test can wait a follow-up PR. If you don't mind uncommenting this code, the PR is good to merge.
|
@bors r+ |
|
📌 Commit 76c6845 has been approved by |
…askrgr Rollup of 6 pull requests Successful merges: - rust-lang#97609 (Iterate over `maybe_unused_trait_imports` when checking dead trait imports) - rust-lang#97688 (test const_copy to make sure bytewise pointer copies are working) - rust-lang#97707 (Improve soundness of rustc_data_structures) - rust-lang#97731 (Add regresion test for rust-lang#87142) - rust-lang#97735 (Don't generate "Impls on Foreign Types" for std) - rust-lang#97737 (Fix pretty printing named bound regions under -Zverbose) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Closes #96873
r? @cjgillot
Some questions, if you have time:
rustc_data_structures::fx::FxIndexSetpath in the query declaration? I wasn't sure where to put ause.is_dummy()call incheck_crate? I don't see failing tests when I comment it out. Should I just try to determine whether dummy spans can ever be put intomaybe_unused_trait_imports?let-elsewithunreachable!()bad? (i.e is there a better idiom? Wouldpanic!("<explanation>")be better?)Vecas mentioned in Iterate overmaybe_unused_trait_importswhen checking dead trait imports #96873, is the best way to use the CI or is it feasible locally?Thanks :)