-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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 boolparameter 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_patinsrc/librustc_lint/unused.rs. - Add a
check_pat_postmethod with an identical signature below it. - Remove the
visit_subpatscondition 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_postat the end. - Add a
Option<NodeId>field toEllipsisInclusiveRangePatternsinrust/src/librustc_lint/builtin.rs
Line 1289 in 6ed6f14
declare_lint_pass!(EllipsisInclusiveRangePatterns => [ELLIPSIS_INCLUSIVE_RANGE_PATTERNS]);
(Look atDeprecatedAttrfor an example of a lint with fields.)
You'll also need to initialise it withNonehere:
Line 97 in 6ed6f14
EllipsisInclusiveRangePatterns: EllipsisInclusiveRangePatterns, - This should be replaced with an assignment of the new field in
EllipsisInclusiveRangePatternstopat.id:
rust/src/librustc_lint/builtin.rs
Line 1315 in 6ed6f14
*visit_subpats = false; check_patshould be early-exited if the field isSome(..).- Add a
check_pat_postimplementation toEllipsisInclusiveRangePatternsand reset the field toNoneif 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.