-
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
Fix is_from_proc_macro
patterns
#11538
Conversation
r? @dswij (rustbot has picked a reviewer for you, use r? to override) |
Finally, after a few months I finally release this 0.9.9 version of the final 'is_from_proc_macro'. The main changes happen on: - Moving 'check_from_proc_macro.rs' from Clippy to rustc_lint - Applying a Jarcho's (yet to be merged) fix to that file (See rust-lang/rust-clippy#11538) - Change every occurence of 'is_from_proc_macro' to 'cx.in_proc_macro' - Added a new macro to 'rustc_lint/late.rs', now it checks if we're in Clippy, if we are indeed in Clippy, check if we're in a proc macro. - Apply some parallization to the checking with already provided functions (nothing too fancy, just using a parallization function) - Fix a bug on 'min_ident_chars.rs' - A few more things I don't remember... You can test this commit with 'RUST_BACKTRACE=full x test src/tools/clippy --keep-stage=2'
Finally, after a few months I finally release this 0.9.9 version of the final 'is_from_proc_macro'. The main changes happen on: - Moving 'check_from_proc_macro.rs' from Clippy to rustc_lint - Applying a Jarcho's (yet to be merged) fix to that file (See rust-lang/rust-clippy#11538) - Change every occurence of 'is_from_proc_macro' to 'cx.in_proc_macro' - Added a new macro to 'rustc_lint/late.rs', now it checks if we're in Clippy, if we are indeed in Clippy, check if we're in a proc macro. - Apply some parallization to the checking with already provided functions (nothing too fancy, just using a parallization function) - Fix a bug on 'min_ident_chars.rs' - A few more things I don't remember... You can test this commit with 'RUST_BACKTRACE=full x test src/tools/clippy --keep-stage=2'
r? @Centri3 |
Maybe some optimizing would be pretty cool, we have a 3-second slowdown just from this PR on benchmarks. |
Those results are quite suspicious given that part of this involves changing |
Got around to checking this. Testing was done on the current master and this pr rebased onto it. Timed command is |
☔ The latest upstream changes (presumably #11747) 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.
This overall looks good to me, I just want some clarification regarding parenthesis.
clippy_utils/src/check_proc_macro.rs
Outdated
@@ -125,6 +121,7 @@ fn qpath_search_pat(path: &QPath<'_>) -> (Pat, Pat) { | |||
fn expr_search_pat(tcx: TyCtxt<'_>, e: &Expr<'_>) -> (Pat, Pat) { | |||
match e.kind { | |||
ExprKind::ConstBlock(_) => (Pat::Str("const"), Pat::Str("}")), | |||
// Parenthesis are skipped before the patterns are matched. |
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.
This comment doesn't make much sense to me. I recall expressions within ExprKind::Paren
retain the parenthesis' span? Can you elaborate on this further? Is this special for Tup
?
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.
It's referring to how the search patterns are matched to the source text. It's why the head and tail patterns for an empty tuple appear flipped.
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 think I understand now. Can you update this comment then? Perhaps:
// Parentheses are skipped before the patterns are matched. With a non-empty tuple, the head/tail pattern will be the first/last expression - with an empty tuple, there are no expressions, so using the next/previous token will flip the parentheses
(If that's why anyway.)
This is ready after
Today is backport day. This PR isn't merged yet. What's the motivation behind backporting this? If this is only for performance improvements, I'd rather not backport it. |
The first commit has an ICE fix. |
As this is not merged yet, I'll include this backport in the next release cycle. |
☔ The latest upstream changes (presumably #11750) made this pull request unmergeable. Please resolve the merge conflicts. |
@bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
The first commit is already contained in the Rust upstream |
Nvm, beta was apparently branched 1 day earlier than usual. I'll try to figure out how to backport those PRs anyway. |
…troalbini [beta] Clippy beta backport PR towards stable, as beta was branched a day early and I missed the notification. - rust-lang/rust-clippy#11538 - rust-lang/rust-clippy#11756 - rust-lang/rust-clippy#11760 - rust-lang/rust-clippy#11953 r? `@pietroalbini`
…troalbini [beta] Clippy beta backport PR towards stable, as beta was branched a day early and I missed the notification. - rust-lang/rust-clippy#11538 - rust-lang/rust-clippy#11756 - rust-lang/rust-clippy#11760 - rust-lang/rust-clippy#11953 r? `@pietroalbini`
fixes #11533
changelog: none