From bbe0e9b2ee7d1181747fc7cadbaa5e964b7ff1c6 Mon Sep 17 00:00:00 2001 From: Matt Hauck Date: Wed, 18 Oct 2023 11:55:45 -0700 Subject: [PATCH] Update rust and fix lint --- Dockerfile.build | 2 +- lib/src/github/api.rs | 10 +++++----- lib/src/github/models.rs | 2 +- lib/src/version.rs | 21 ++++++++++----------- octobot/src/server/github_handler.rs | 4 ++-- ops/src/pr_merge.rs | 2 +- 6 files changed, 20 insertions(+), 21 deletions(-) diff --git a/Dockerfile.build b/Dockerfile.build index e48be8d6..901ce6f2 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -19,7 +19,7 @@ RUN apt-get update \ && rm -fr /var/lib/apt/lists/ ENV PATH $PATH:/root/.cargo/bin -ENV RUST_VERSION 1.71.1 +ENV RUST_VERSION 1.73.0 # install rust RUN curl -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain "$RUST_VERSION" \ diff --git a/lib/src/github/api.rs b/lib/src/github/api.rs index 6139a497..dd33fcf4 100644 --- a/lib/src/github/api.rs +++ b/lib/src/github/api.rs @@ -374,7 +374,7 @@ impl GithubSession { ) -> Result { let mut headers = reqwest::header::HeaderMap::new(); - let accept_headers = vec![ + let accept_headers = [ // standard header "application/vnd.github.v3+json", // timeline api @@ -460,7 +460,7 @@ impl GithubSession { } } - pull_requests.extend(next_prs.into_iter()); + pull_requests.extend(next_prs); page += 1; } Ok(pull_requests) @@ -652,7 +652,7 @@ impl Session for GithubSession { break; } - result.extend(next.into_iter()); + result.extend(next); page += 1; } @@ -885,7 +885,7 @@ impl Session for GithubSession { break; } - events.extend(next_events.into_iter()); + events.extend(next_events); page += 1; } @@ -1037,7 +1037,7 @@ impl Session for GithubSession { let done = results.iter().any(|d| d.guid == guid); - result.extend(results.into_iter()); + result.extend(results); if done { break; diff --git a/lib/src/github/models.rs b/lib/src/github/models.rs index b323f4af..5288c042 100644 --- a/lib/src/github/models.rs +++ b/lib/src/github/models.rs @@ -279,7 +279,7 @@ impl PullRequest { pub fn all_reviewers(&self) -> Vec { let mut reviewers = vec![]; if let Some(ref requested_reviewers) = self.requested_reviewers { - reviewers.extend(requested_reviewers.clone().into_iter()); + reviewers.extend(requested_reviewers.clone()); } if let Some(ref reviews) = self.reviews { diff --git a/lib/src/version.rs b/lib/src/version.rs index 0bed5217..e5be5195 100644 --- a/lib/src/version.rs +++ b/lib/src/version.rs @@ -58,17 +58,23 @@ impl Eq for Version {} impl PartialOrd for Version { fn partial_cmp(&self, other: &Version) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for Version { + fn cmp(&self, other: &Version) -> Ordering { // Note: this is always going to be at least 3. let min_len = cmp::min(self.parts.len(), other.parts.len()); for i in 0..min_len { let result = self.parts[i].cmp(&other.parts[i]); if !result.is_eq() { - return Some(result); + return result; } } if self.parts.len() == other.parts.len() { - return Some(Ordering::Equal); + return Ordering::Equal; } // if all else is equal, but one of the Versions has more elements, @@ -84,18 +90,11 @@ impl PartialOrd for Version { } for part in longer_parts.iter().skip(min_len) { if *part != 0 { - return Some(nonzero_answer); + return nonzero_answer; } } - Some(Ordering::Equal) - } -} - -impl Ord for Version { - fn cmp(&self, other: &Version) -> Ordering { - // we never return None - self.partial_cmp(other).unwrap() + Ordering::Equal } } diff --git a/octobot/src/server/github_handler.rs b/octobot/src/server/github_handler.rs index edd9d6c5..d03e74d5 100644 --- a/octobot/src/server/github_handler.rs +++ b/octobot/src/server/github_handler.rs @@ -514,12 +514,12 @@ impl GithubEventHandler { for t in teams { let team_members = self.team_members_cache.get(repo, t.id); if let Some(team_members) = team_members { - participants.extend(team_members.into_iter()); + participants.extend(team_members); } else { let team_members = self.github_session.get_team_members(repo, t.id).await; match team_members { Ok(m) => { - participants.extend(m.clone().into_iter()); + participants.extend(m.clone()); self.team_members_cache.insert(repo, t.id, m); } Err(e) => { diff --git a/ops/src/pr_merge.rs b/ops/src/pr_merge.rs index 239a731d..3c0b1b1f 100644 --- a/ops/src/pr_merge.rs +++ b/ops/src/pr_merge.rs @@ -301,7 +301,7 @@ fn do_cherry_pick( let mut args = vec!["-c", "merge.renameLimit=999999"]; args.extend(user_opts.iter()); - args.extend(vec!["cherry-pick", "--allow-empty"].iter()); + args.extend(["cherry-pick", "--allow-empty"].iter()); args.extend(opts); args.push(commit_hash);