-
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
More proc-macro detection #8694
Conversation
r? @Manishearth (rust-highfive has picked a reviewer for you, use r? to override) |
c6c5d56
to
f1b3615
Compare
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 don't understand: don't we already have utils functions that check for external macros? Spans do get augmented if they're from proc macros
Also this seems to rely on some very specific span behavior in rustc, I'd like to see a lot more tests specific to this.
cc @rust-lang/clippy
The proc-macro issue is from using something like |
Ah, I see! |
Do we need to separate the |
A thing to point out is |
It shouldn't be so expensive that we can't run them at the same time. |
@Jarcho right, but |
True. But, Ideally it would be run once for all lint passes, but that's a totally different problem. |
Hm, fair! |
Gonna unassign myself from complex PRs for a while since I'm a bit swamped. |
☔ The latest upstream changes (presumably #8563) made this pull request unmergeable. Please resolve the merge conflicts. |
I mean we could just stop linting in external macros altogether: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint_defs/struct.Lint.html#structfield.report_in_external_macro rust-clippy/clippy_lints/src/lib.rs Lines 103 to 108 in c0fce5a
I think last time we thought about doing this, we decided to not do it for some reason, I can't remember anymore. Maybe we can continue linting in external macros in |
@flip1995 that might be good! I think overall for things like, for example, the clippy unwrap lints, folks might want them to lint inside macros. It's also tricky because "external" may still mean "in same workspace". |
Good point, but then external macros would be just like external function calls. Clippy also doesn't look into those. It may make sense then that in the
True, but we don't have a good way to check this AFAIK |
da3543a
to
79deff1
Compare
☔ The latest upstream changes (presumably #8918) made this pull request unmergeable. Please resolve the merge conflicts. |
r? @xFrednet Turns out nobody is assigned here. Time to bother somebody without a long review queue. |
Psst, before somebody else notices xD. Totally fine, I'll add this to my backlog. Would you mind rebasing? 🙃 |
856b11c
to
bc25171
Compare
Hey @Jarcho, sadly, I'm a bit swarmed with RL stuff at the moment. It will take a bit longer until I can do a full review, but it's still on my todo list :) |
Feel free to pass it off to someone else if needed. |
☔ The latest upstream changes (presumably #9182) made this pull request unmergeable. Please resolve the merge conflicts. |
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.
The implementation looks good to me, I have some smaller suggestions and questions just to make sure that everything is correct. If they have been solved, we can merge this.
Also, thank you for your patience. The next review should be much quicker!
Out of interest, have you done any kind of benchmarks of this implementation? I suspect that it shouldn't add much, if the check is directly before the lint emission. Still, it could be interesting 🙃
c01d2d1
to
745b194
Compare
Looks good to me. Thank you for this implementation, I'm interested to see if we get any new FPs with this new checks 🙃 @bors r+ |
More proc-macro detection fixes #6514 fixes #8683 fixes #6858 fixes #6594 This is a more general way of checking if an expression comes from a macro and could be trivially applied to other lints. Ideally this would be fixed in rustc's proc-macro api, but I don't see that happening any time soon. changelog: Don't lint `unit_arg` when generated by a proc-macro.
@bors r- (The changelog entries are not yet up to day) |
Updated the changelog entry. @bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Use `check_proc_macro` for `missing_const_for_fn` This uses `@Jarcho's` #8694 implementation to fix `missing_const_for_fn` linting in proc-macros. I'm not 100% sure what I'm doing here, any feedback is appreciated. Previously: Jarcho#1. Fixes #8854. changelog: [`missing_const_for_fn`]: No longer lints in proc-macros
fixes #6514
fixes #8683
fixes #6858
fixes #6594
This is a more general way of checking if an expression comes from a macro and could be trivially applied to other lints. Ideally this would be fixed in rustc's proc-macro api, but I don't see that happening any time soon.
changelog: FPs: [
unit_arg
] [default_trait_access
] [missing_docs_in_private_items
]: No longer trigger in code generated from proc-macros.