-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
C-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
The visit_subpats
parameter is a hack (to fix a problem with range patterns) that should be refactored. The idea is that the state should be contained in EllipsisInclusiveRangePatterns
instead.
This should be straightforward to fix.
- Remove the
&mut bool
parameter from
Line 374 in 6ed6f14
fn check_pat(a: &ast::Pat, b: &mut bool); // FIXME: &mut bool looks just broken
(You'll also need to update the signature ofcheck_pat
insrc/librustc_lint/unused.rs
. - Add a
check_pat_post
method with an identical signature below it. - Remove the
visit_subpats
condition fromrust/src/librustc/lint/context.rs
Lines 1166 to 1173 in 6ed6f14
fn visit_pat(&mut self, p: &'a ast::Pat) { let mut visit_subpats = true; run_early_pass!(self, check_pat, p, &mut visit_subpats); self.check_id(p.id); if visit_subpats { ast_visit::walk_pat(self, p); } } - Run an early lint pass for
check_pat_post
at the end. - Add a
Option<NodeId>
field toEllipsisInclusiveRangePatterns
inrust/src/librustc_lint/builtin.rs
Line 1289 in 6ed6f14
declare_lint_pass!(EllipsisInclusiveRangePatterns => [ELLIPSIS_INCLUSIVE_RANGE_PATTERNS]);
(Look atDeprecatedAttr
for an example of a lint with fields.)
You'll also need to initialise it withNone
here:
Line 97 in 6ed6f14
EllipsisInclusiveRangePatterns: EllipsisInclusiveRangePatterns, - This should be replaced with an assignment of the new field in
EllipsisInclusiveRangePatterns
topat.id
:
rust/src/librustc_lint/builtin.rs
Line 1315 in 6ed6f14
*visit_subpats = false; check_pat
should be early-exited if the field isSome(..)
.- Add a
check_pat_post
implementation toEllipsisInclusiveRangePatterns
and reset the field toNone
if the pattern ID matches the field ID. - Make sure the UI tests still pass with no changes.
Metadata
Metadata
Assignees
Labels
C-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
stepnivlk commentedon Apr 17, 2019
hi @varkor, I'm happy to take care of this one if it's not taken already.
varkor commentedon Apr 17, 2019
@stepnivlk: go ahead! Let me know if you have any questions or problems with the implementation! :)
visit_subpats
parameter fromcheck_pat
#60152Auto merge of #60152 - stepnivlk:visit_subpats-removal, r=varkor