-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add new lint manual_duration_calcs
#6490
Conversation
…ntation_as_secs_f64_for_div
WIP cargo fmt WIP
WIP WIP WIP fix WIP
WIP WIP WIP
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @flip1995 (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Rename from manual_re_implementation_as_secs_f64_for_mul to manual_re_implementation_lower_the_unit
Aligh arguments order with other functions.
…_implementation_upper_the_unit
It seems to fail dogfood test. |
I'm doing refactoring now to do pass the dogfood test. |
Because I wanted to use this type other than divison parse.
Remove Numeral struct
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.
Yes, please do some refactoring. Splitting things up in functions will help a lot.
{ | ||
if_chain! { | ||
if let Some((mul_ident, mul_receiver, multiplier, plus_ident, plus_receiver, plus_cast_type)) = | ||
match (&left.kind, &right.kind) { |
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.
Please refactor this out in an extra function.
} | ||
|
||
#[derive(Debug)] | ||
enum Number { |
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.
Also this. enums in fn in impls is a bit too deep IMO.
This case ``` let _secs_f64_1 = (dur.as_secs() as f64 * 1_000.0 + dur.subsec_millis() as f64) / 1000.0; ```
This reverts commit a00c908.
error: no manual re-implementationa of the as_millis | ||
--> $DIR/manual_duration_calcs.rs:33:23 | ||
| | ||
LL | let _secs_f64_1 = (dur.as_secs() as f64 * 1_000.0 + dur.subsec_millis() as f64) / 1000.0; |
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.
It seems to fail tests at this line and next line. I haven't checked that in detail, but the lint is emitted twice here and rustfix seems to fail.
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.
I know rustfix conflicting between manual_re_implementation_lower_the_unit
and duration_as_secs
when this pattern.
let _secs_f64_1 = (dur.as_secs() as f64 * 1_000.0 + dur.subsec_millis() as f64) / 1000.0
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ manual_re_implementation_lower_the_unit
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ duration_as_secs
I am in trouble at can't resolve this conflict.
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.
IMHO, how about checking if parent expression in manual_re_implementation_lower_the_unit
sees duration_as_secs
?
Those are a huge amount of changes to the code, introducing multiple functions. It would take me a day to understand what every function/struct does (i.e. what pattern it matches). Please add more (doc) comments explaining the functions and structs introduced in this PR. |
☔ The latest upstream changes (presumably #6591) made this pull request unmergeable. Please resolve the merge conflicts. |
ping from triage @himanoa. Can you add these?
|
ping from triage @himanoa. According to the triage procedure, I'm closing this because 2 weeks have passed with no activity. If you have more time to work on this, feel free to reopen this. |
fixes #6068
.stderr
file)cargo test
passes locallycargo dev update_lints
cargo dev fmt
Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.
Delete this line and everything above before opening your PR.
changelog: Add new lint
manual_duration_calcs