Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Remove visit_subpats parameter from check_pat #60152

Merged
merged 1 commit into from
Apr 23, 2019
Merged

Remove visit_subpats parameter from check_pat #60152

merged 1 commit into from
Apr 23, 2019

Conversation

stepnivlk
Copy link
Contributor

@stepnivlk stepnivlk commented Apr 21, 2019

The core idea is to keep track of current ID directly in EllipsisInclusiveRangePatterns struct and early return in check_pat based on it.

Fixes #60043.

r? @varkor

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 21, 2019

impl_lint_pass!(EllipsisInclusiveRangePatterns => [ELLIPSIS_INCLUSIVE_RANGE_PATTERNS]);

impl EllipsisInclusiveRangePatterns {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can #[derive(Default)] for this instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@Centril Centril Apr 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

Copy link
Member

@varkor varkor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me! Just a couple of tiny comments about formatting (and adding a couple of comments).


impl EarlyLintPass for EllipsisInclusiveRangePatterns {
fn check_pat(&mut self, cx: &EarlyContext<'_>, pat: &ast::Pat, visit_subpats: &mut bool) {
fn check_pat(&mut self, cx: &EarlyContext<'_>, pat: &ast::Pat) {
if let Some(_node_id) = self.node_id { return }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
}

@@ -1286,10 +1286,24 @@ declare_lint! {
"`...` range patterns are deprecated"
}

declare_lint_pass!(EllipsisInclusiveRangePatterns => [ELLIPSIS_INCLUSIVE_RANGE_PATTERNS]);
pub struct EllipsisInclusiveRangePatterns {
node_id: Option<ast::NodeId>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
node_id: Option<ast::NodeId>,
/// If `Some(_)`, suppress all subsequent pattern
/// warnings for better diagnostics.
node_id: Option<ast::NodeId>,


fn check_pat_post(&mut self, _cx: &EarlyContext<'_>, pat: &ast::Pat) {
if let Some(node_id) = self.node_id {
if pat.id == node_id { self.node_id = None }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if pat.id == node_id { self.node_id = None }
if pat.id == node_id {
self.node_id = None;
}

(Blocks should be on new lines.)

@stepnivlk
Copy link
Contributor Author

@Centril issue was filed, thx for the info.
@varkor PR was updated according to your comments, thx for it and introducing me to lints :)

@varkor
Copy link
Member

varkor commented Apr 22, 2019

@stepnivlk: thanks!

@bors r+

@bors
Copy link
Contributor

bors commented Apr 22, 2019

📌 Commit 1dc13b5 has been approved by varkor

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 22, 2019
bors added a commit that referenced this pull request Apr 23, 2019
Remove `visit_subpats` parameter from `check_pat`

The core idea is to keep track of current ID directly in `EllipsisInclusiveRangePatterns` struct and early return in `check_pat` based on it.

Fixes #60043.

r? @varkor
@bors
Copy link
Contributor

bors commented Apr 23, 2019

⌛ Testing commit 1dc13b5 with merge fe0a415...

@bors
Copy link
Contributor

bors commented Apr 23, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: varkor
Pushing fe0a415 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 23, 2019
@bors bors merged commit 1dc13b5 into rust-lang:master Apr 23, 2019
@rust-highfive
Copy link
Collaborator

📣 Toolstate changed by #60152!

Tested on commit fe0a415.
Direct link to PR: #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).

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Apr 23, 2019
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).
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove visit_subpats parameter from check_pat
5 participants