Closed
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
(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
- 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
(Look atDeprecatedAttr
for an example of a lint with fields.)
You'll also need to initialise it withNone
here:
Line 97 in 6ed6f14
- 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
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
Category: PRs that clean code up or issues documenting cleanup.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Relevant to the compiler team, which will review and decide on the PR/issue.