Skip to content

Commit

Permalink
Pull check_param_name out of match
Browse files Browse the repository at this point in the history
Summary: Less code (and safer).

Reviewed By: JakobDegen

Differential Revision: D62703967

fbshipit-source-id: c159ab0ecc2222cc4de3f39bf5e3b92373f65898
  • Loading branch information
stepancheg authored and facebook-github-bot committed Sep 18, 2024
1 parent 6abbca8 commit ec99104
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions starlark_syntax/src/syntax/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ impl<'a, P: AstPayload> DefParams<'a, P> {

for (i, param) in ast_params.iter().enumerate() {
let span = param.span;

if let Some(name) = param.ident() {
check_param_name(&mut argset, name, param, codemap)?;
}

match &param.node {
ParameterP::Normal(n, ty, None) => {
if seen_kwargs || (seen_optional && !seen_args) {
Expand All @@ -99,7 +104,6 @@ impl<'a, P: AstPayload> DefParams<'a, P> {
codemap,
));
}
check_param_name(&mut argset, n, param, codemap)?;
params.push(Spanned {
span,
node: DefParam {
Expand All @@ -118,7 +122,6 @@ impl<'a, P: AstPayload> DefParams<'a, P> {
));
}
seen_optional = true;
check_param_name(&mut argset, n, param, codemap)?;
params.push(Spanned {
span,
node: DefParam {
Expand Down Expand Up @@ -162,7 +165,6 @@ impl<'a, P: AstPayload> DefParams<'a, P> {
));
}
seen_args = true;
check_param_name(&mut argset, n, param, codemap)?;
params.push(Spanned {
span,
node: DefParam {
Expand All @@ -181,7 +183,6 @@ impl<'a, P: AstPayload> DefParams<'a, P> {
));
}
seen_kwargs = true;
check_param_name(&mut argset, n, param, codemap)?;
params.push(Spanned {
span,
node: DefParam {
Expand Down

0 comments on commit ec99104

Please sign in to comment.