Remove visit_subpats parameter from check_pat #60152
Conversation
There was a problem hiding this comment.
You can #[derive(Default)] for this instead.
There was a problem hiding this comment.
I chose it b/c of consistency, there's new on other linters, e.g. https://github.com/rust-lang/rust/blob/5160955b96636db3b3b70a348c53454e73473538/src/librustc_lint/builtin.rs#L552 and https://github.com/rust-lang/rust/blob/5160955b96636db3b3b70a348c53454e73473538/src/librustc_lint/lib.rs#L99
#[derive(Default)] would give me default method
There was a problem hiding this comment.
@stepnivlk To achieve semantic compression, it seems preferable to use #[derive(Default)] wherever possible for these lints. Could you file an issue for converting all places in a different PR?
varkor
left a comment
There was a problem hiding this comment.
This looks good to me! Just a couple of tiny comments about formatting (and adding a couple of comments).
There was a problem hiding this comment.
| if let Some(_node_id) = self.node_id { return } | |
| if self.node_id.is_some() { | |
| // Don't recursively warn about patterns inside range endpoints. | |
| return | |
| } |
There was a problem hiding this comment.
| node_id: Option<ast::NodeId>, | |
| /// If `Some(_)`, suppress all subsequent pattern | |
| /// warnings for better diagnostics. | |
| node_id: Option<ast::NodeId>, |
There was a problem hiding this comment.
| if pat.id == node_id { self.node_id = None } | |
| if pat.id == node_id { | |
| self.node_id = None; | |
| } |
(Blocks should be on new lines.)
…usiveRangePatterns
|
@stepnivlk: thanks! @bors r+ |
|
📌 Commit 1dc13b5 has been approved by |
|
☀️ Test successful - checks-travis, status-appveyor |
|
📣 Toolstate changed by #60152! Tested on commit fe0a415. 💔 clippy-driver on windows: test-fail → build-fail (cc @Manishearth @llogiq @mcarton @oli-obk @phansch, @rust-lang/infra). |
Tested on commit rust-lang/rust@fe0a415. Direct link to PR: <rust-lang/rust#60152> 💔 clippy-driver on windows: test-fail → build-fail (cc @Manishearth @llogiq @mcarton @oli-obk @phansch, @rust-lang/infra). 💔 clippy-driver on linux: test-fail → build-fail (cc @Manishearth @llogiq @mcarton @oli-obk @phansch, @rust-lang/infra). 💔 rls on windows: test-fail → build-fail (cc @Xanewok, @rust-lang/infra). 💔 rls on linux: test-fail → build-fail (cc @Xanewok, @rust-lang/infra).
The core idea is to keep track of current ID directly in
EllipsisInclusiveRangePatternsstruct and early return incheck_patbased on it.Fixes #60043.
r? @varkor