-
Notifications
You must be signed in to change notification settings - Fork 131
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
Fix clippy::match_same_arms #1433
Fix clippy::match_same_arms #1433
Conversation
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.
Reviewed 10 of 10 files at r1, all commit messages.
Reviewable status: 0 of 1 LGTMs obtained, and all files reviewed, and 8 discussions need to be resolved
nativelink-metric/src/lib.rs
line 75 at r1 (raw file):
2 => MetricKind::String, 3 => MetricKind::Component, 4_u64..=u64::MAX => todo!(),
Shouldn't this be MetricKind::Default
?
nativelink-metric-collector/src/metrics_visitors.rs
line 37 at r1 (raw file):
MetricKind::Counter => CollectionKind::Counter, MetricKind::String => CollectionKind::String, MetricKind::Default | MetricKind::Component => todo!(),
Shouldn't this be CollectionKind::String
?
nativelink-scheduler/src/store_awaited_action_db.rs
line 238 at r1 (raw file):
impl OperationIdToAwaitedAction<'_> { fn borrow(&self) -> OperationIdToAwaitedAction<'_> { OperationIdToAwaitedAction(Cow::Borrowed(self.0.as_ref()))
Could you elaborate why this is equivalent?
nativelink-util/src/platform_properties.rs
line 118 at r1 (raw file):
match self { Self::Exact(value) | Self::Priority(value) | Self::Unknown(value) => { Cow::Borrowed(&**value)
Why add the &**
here?
nativelink-util/src/retry.rs
line 101 at r1 (raw file):
} else { match code { // Variants that return `false`
nit: Remove comment
nativelink-util/src/retry.rs
line 111 at r1 (raw file):
| Code::Unauthenticated => false, // Variants that return `true`
nit: Remove comment
nativelink-util/src/retry.rs
line 121 at r1 (raw file):
| Code::DataLoss => true, // Handle any other variants
nit: Remove comment
nativelink-util/src/retry.rs
line 122 at r1 (raw file):
// Handle any other variants _ => todo!(),
Try to avoid todo!()
into potentially reachable code. I'd keep this as true
.
7f08adb
to
3227214
Compare
3227214
to
ca9b44e
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.
Reviewable status: 0 of 1 LGTMs obtained, and 4 of 10 files reviewed, and pending CI: Bazel Dev / macos-13, Bazel Dev / macos-14, Bazel Dev / ubuntu-24.04, Cargo Dev / macos-13, Cargo Dev / ubuntu-22.04, Coverage, Installation / macos-13, Installation / macos-14, Installation / ubuntu-22.04, Local / ubuntu-22.04, NativeLink.com Cloud / Remote Cache / macos-14, NativeLink.com Cloud / Remote Cache / ubuntu-24.04, Publish image, Publish nativelink-worker-init, Publish nativelink-worker-lre-cc, Remote / large-ubuntu-22.04, asan / ubuntu-22.04, docker-compose-compiles-nativelink (22.04), integration-tests (22.04), macos-13, pre-commit-checks, ubuntu-20.04 / stable, ubuntu-22.04, ubuntu-22.04 / stable, windows-2022 / stable, and 5 discussions need to be resolved
nativelink-metric/src/lib.rs
line 75 at r1 (raw file):
Previously, aaronmondal (Aaron Siddhartha Mondal) wrote…
Shouldn't this be
MetricKind::Default
?
This is the suggestion from the clippy lint. The case for u64::MAX wasn't covered. We should find a way to test all cases properly in future. For now i have set it to MetricKind::Default,
nativelink-metric-collector/src/metrics_visitors.rs
line 37 at r1 (raw file):
Previously, aaronmondal (Aaron Siddhartha Mondal) wrote…
Shouldn't this be
CollectionKind::String
?
Fixed this.
nativelink-scheduler/src/store_awaited_action_db.rs
line 238 at r1 (raw file):
Previously, aaronmondal (Aaron Siddhartha Mondal) wrote…
Could you elaborate why this is equivalent?
Sure! In the previous version, the borrow
method checks whether self.0
is a Cow::Borrowed
or Cow::Owned
variant. In both cases, a new OperationIdToAwaitedAction
is created with a Cow::Borrowed
.
We can simplify this by directly creating the OperationIdToAwaitedAction
and passing a reference to it, whether it's borrowed or owned, by using the as_ref
function.
The as_ref()
method is called on self.0
, which always returns a reference to the inner value, regardless of whether self.0
is Borrowed
or Owned
.
nativelink-util/src/platform_properties.rs
line 118 at r1 (raw file):
Previously, aaronmondal (Aaron Siddhartha Mondal) wrote…
Why add the
&**
here?
Fixed.
nativelink-util/src/retry.rs
line 122 at r1 (raw file):
Previously, aaronmondal (Aaron Siddhartha Mondal) wrote…
Try to avoid
todo!()
into potentially reachable code. I'd keep this astrue
.
I replaced all cases which return true with a wildcard match which returns true and commented that as a todo.
We probably need to handle all cases so there is no need for a wildcard match in future.
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.
Reviewed 6 of 6 files at r2, all commit messages.
Reviewable status:complete! 1 of 1 LGTMs obtained, and all files reviewed
How Has This Been Tested?
bazel test ...
Checklist
bazel test //...
passes locallygit amend
see some docsThis change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)