-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Iterate over maybe_unused_trait_imports
when checking dead trait imports
#97609
Conversation
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Elliot-Roberts! This looks very good. I left a few comments.
let item = tcx.hir().expect_item(id); | ||
// if item.span.is_dummy() { | ||
// continue; | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
38abfa4
to
f8991fc
Compare
f8991fc
to
76c6845
Compare
@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::FxIndexSet
path 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-else
withunreachable!()
bad? (i.e is there a better idiom? Wouldpanic!("<explanation>")
be better?)Vec
as mentioned in Iterate overmaybe_unused_trait_imports
when checking dead trait imports #96873, is the best way to use the CI or is it feasible locally?Thanks :)