Remove visit_subpats
parameter from check_pat
#60043
Labels
C-cleanup
Category: PRs that clean code up or issues documenting cleanup.
E-easy
Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
E-mentor
Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
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 inEllipsisInclusiveRangePatterns
instead.This should be straightforward to fix.
&mut bool
parameter fromrust/src/librustc/lint/mod.rs
Line 374 in 6ed6f14
(You'll also need to update the signature of
check_pat
insrc/librustc_lint/unused.rs
.check_pat_post
method with an identical signature below it.visit_subpats
condition fromrust/src/librustc/lint/context.rs
Lines 1166 to 1173 in 6ed6f14
check_pat_post
at the end.Option<NodeId>
field toEllipsisInclusiveRangePatterns
inrust/src/librustc_lint/builtin.rs
Line 1289 in 6ed6f14
(Look at
DeprecatedAttr
for an example of a lint with fields.)You'll also need to initialise it with
None
here:rust/src/librustc_lint/lib.rs
Line 97 in 6ed6f14
EllipsisInclusiveRangePatterns
topat.id
:rust/src/librustc_lint/builtin.rs
Line 1315 in 6ed6f14
check_pat
should be early-exited if the field isSome(..)
.check_pat_post
implementation toEllipsisInclusiveRangePatterns
and reset the field toNone
if the pattern ID matches the field ID.The text was updated successfully, but these errors were encountered: