New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(counter_style): parse int via parse_non_negative #20368
Conversation
Heads up! This PR modifies the following files:
|
e8c8862
to
9790155
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
try_match_ident_ignore_ascii_case! { input, | ||
"cyclic" => Ok(System::Cyclic), | ||
"numeric" => Ok(System::Numeric), | ||
"alphabetic" => Ok(System::Alphabetic), | ||
"symbolic" => Ok(System::Symbolic), | ||
"additive" => Ok(System::Additive), | ||
"fixed" => { | ||
let first_symbol_value = input.try(|i| i.expect_integer()).ok(); | ||
let first_symbol_value = Integer::parse_non_negative(context, input) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong, this needs to be:
let first_symbol_value = input.try(|i| Integer::parse_non_negative(context, i)).ok();
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And first_symbol_value
needs to start taking an Integer
instead of an i32.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Err, and this doesn't really need to be non-negative, so should be:
let first_symbol_value = input.try(|i| Integer::parse(context, i)).ok();
let symbol = symbol.or_else(|_| Symbol::parse(context, input))?; | ||
Ok(AdditiveTuple { | ||
weight: weight as u32, | ||
weight: weight.value() as u32, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weight
should become an Integer
.
let pad_with = pad_with.or_else(|_| Symbol::parse(context, input))?; | ||
Ok(Pad(min_length as u32, pad_with)) | ||
Ok(Pad(min_length.value() as u32, pad_with)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first member of Pad
should become an Integer, not a u32
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Err, I meant to request changes above :)
9790155
to
6675e16
Compare
@emilio appreciate for review, tried to update as suggested. Wasn't entirely sure if I could update types to take |
6675e16
to
3d6a625
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Mind sqashing the commits?
*squashing, that is :) |
3d6a625
to
c8592ea
Compare
@emilio sure, rebased to master and squashed into single commit. |
@bors-servo r+ Thank you! |
📌 Commit c8592ea has been approved by |
refactor(counter_style): parse int via parse_non_negative <!-- Please describe your changes on the following line: --> Relates to #20332. This PR intends to refactor `counter_style` to use `parse_non_negative` where applicable, mostly which uses `expect_integer` currently. Change still grabs value from parsed result then assign it into each struct as needed and does not change definition of struct (i.e `AdditiveTuple`) itself. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #20332 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ - This PR has locally built & ran unit test on macOS. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20368) <!-- Reviewable:end -->
💔 Test failed - linux-rel-css |
@bors-servo retry |
⚡ Previous build results for android, arm32, arm64, linux-dev, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev are reusable. Rebuilding only linux-rel-css... |
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
Relates to #20332.
This PR intends to refactor
counter_style
to useparse_non_negative
where applicable, mostly which usesexpect_integer
currently. Change still grabs value from parsed result then assign it into each struct as needed and does not change definition of struct (i.eAdditiveTuple
) itself../mach build -d
does not report any errors./mach test-tidy
does not report any errorsInteger::parse
instead ofexpect_integer
#20332 (github issue number if applicable).This change is