Skip to content

Remove visit_subpats parameter from check_pat #60152

Merged
bors merged 1 commit into
rust-lang:masterfrom
stepnivlk:visit_subpats-removal
Apr 23, 2019
Merged

Remove visit_subpats parameter from check_pat #60152
bors merged 1 commit into
rust-lang:masterfrom
stepnivlk:visit_subpats-removal

Conversation

@stepnivlk

@stepnivlk stepnivlk commented Apr 21, 2019

Copy link
Copy Markdown

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
Comment thread src/librustc_lint/builtin.rs Outdated

Copy link
Copy Markdown
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
Copy Markdown
Author

Choose a reason for hiding this comment

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

@Centril Centril Apr 22, 2019

Copy link
Copy Markdown
Contributor

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?

@varkor varkor left a comment

Copy link
Copy Markdown
Contributor

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).

Comment thread src/librustc_lint/builtin.rs Outdated

Copy link
Copy Markdown
Contributor

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
}

Comment thread src/librustc_lint/builtin.rs Outdated

Copy link
Copy Markdown
Contributor

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>,

Comment thread src/librustc_lint/builtin.rs Outdated

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

varkor commented Apr 22, 2019

Copy link
Copy Markdown
Contributor

@stepnivlk: thanks!

@bors r+

@bors

bors commented Apr 22, 2019

Copy link
Copy Markdown
Collaborator

📌 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

bors commented Apr 23, 2019

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 1dc13b5 with merge fe0a415...

@bors

bors commented Apr 23, 2019

Copy link
Copy Markdown
Collaborator

☀️ 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
Copy Markdown
Contributor

📣 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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in 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