-
-
Notifications
You must be signed in to change notification settings - Fork 719
perf(linter): generate node type info for lint rules with let..else
#13287
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
perf(linter): generate node type info for lint rules with let..else
#13287
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Instrumentation Performance ReportMerging #13287 will improve performances by 71.95%Comparing Summary
Benchmarks breakdown
Footnotes |
7497edb to
ce94493
Compare
ce94493 to
e673f22
Compare
cb6d1d0 to
ce94926
Compare
e673f22 to
8b57262
Compare
ce94926 to
697d103
Compare
8b57262 to
13af599
Compare
efc0e7a to
284c7db
Compare
13af599 to
b272bd6
Compare
284c7db to
52a4734
Compare
b272bd6 to
918b957
Compare
| // Ensure there are no top-level `if` statements before this let-else | ||
| if func | ||
| .block | ||
| .stmts | ||
| .iter() | ||
| .take(idx) | ||
| .any(|s| matches!(s, Stmt::Expr(Expr::If(_), _))) | ||
| { | ||
| return None; | ||
| } |
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.
Is this check enough? This is a contrived example, but something like this would produce the wrong result:
let is_var_decl = matches!(node.kind(), AstKind::VariableDeclaration(_));
for ancestor_kind in ctx.ancestor_kinds(node.id()) {
if matches!(ancestor_kind, AstKind::Function(_)) {
if is_var_decl {
ctx.diagnostic( /* ... */ );
return;
}
break;
}
}
let AstKind::Class(decl) = node.kind() else { return };Maybe safer to bail out if let AstKind::Blah(_) = node.kind() else { return }; isn't the first statement.
Once all the common patterns are all covered, we'll be able to see which rules remain that aren't being identified, and match on more patterns to catch them.
i.e. start conservative and expand from there, rather than risk false positives from being too liberal initially.

No description provided.