From 96637aca7ee004620e35d8d495b33e6601270aca Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Wed, 16 Apr 2025 12:02:36 +0200 Subject: [PATCH] chore: update rust-toolchain Update the rust toolchain version to 1.85. Note that this is not the latest, however, it is the latest available in nixpgs, so this version is good enough for now. --- radicle-cli/src/commands/inspect.rs | 10 ++++----- radicle-cli/src/commands/seed.rs | 3 +-- radicle-cli/src/commands/sync.rs | 2 +- radicle-cli/src/git.rs | 2 +- radicle-cli/src/project.rs | 2 +- radicle-cli/src/terminal/format.rs | 2 +- radicle-cli/src/terminal/patch/timeline.rs | 2 +- radicle-crdt/src/test.rs | 2 +- radicle-crypto/src/lib.rs | 2 +- radicle-fetch/src/git/refs/update.rs | 2 +- radicle-fetch/src/git/repository.rs | 14 ++++++------ radicle-fetch/src/state.rs | 6 +++--- radicle-fetch/src/transport/fetch.rs | 4 ++-- radicle-node/src/lib.rs | 5 +++++ radicle-node/src/wire/frame.rs | 6 +++--- radicle-node/src/wire/varint.rs | 6 +++--- radicle-node/src/worker/upload_pack.rs | 2 +- radicle-term/src/ansi/style.rs | 2 +- radicle-term/src/editor.rs | 1 + radicle-term/src/element.rs | 2 +- radicle-term/src/hstack.rs | 2 +- radicle-term/src/vstack.rs | 4 ++-- radicle/src/cob/cache.rs | 2 +- radicle/src/cob/common.rs | 4 ++-- radicle/src/cob/identity.rs | 6 +++--- radicle/src/cob/issue.rs | 10 ++++----- radicle/src/cob/issue/cache.rs | 25 +++++++++++++++------- radicle/src/cob/job.rs | 6 +++--- radicle/src/cob/patch.rs | 14 ++++++------ radicle/src/cob/patch/cache.rs | 19 ++++++++++------ radicle/src/cob/store.rs | 4 ++-- radicle/src/cob/thread.rs | 2 +- radicle/src/git/canonical.rs | 2 +- radicle/src/node.rs | 5 +---- radicle/src/node/address/store.rs | 7 +++--- radicle/src/node/notifications.rs | 2 +- radicle/src/node/policy/store.rs | 8 +++---- radicle/src/storage/git.rs | 2 +- radicle/src/storage/git/cob.rs | 16 +++++++------- radicle/src/version.rs | 2 +- rust-toolchain.toml | 2 +- 41 files changed, 117 insertions(+), 104 deletions(-) diff --git a/radicle-cli/src/commands/inspect.rs b/radicle-cli/src/commands/inspect.rs index 84ba3cbd..8ea1bbd8 100644 --- a/radicle-cli/src/commands/inspect.rs +++ b/radicle-cli/src/commands/inspect.rs @@ -1,10 +1,10 @@ #![allow(clippy::or_fun_call)] use std::collections::HashMap; use std::ffi::OsString; -use std::path::{Path, PathBuf}; +use std::path::Path; use std::str::FromStr; -use anyhow::{anyhow, Context as _}; +use anyhow::Context as _; use chrono::prelude::*; use radicle::identity::RepoId; @@ -114,12 +114,10 @@ impl Args for Options { if let Ok(val) = RepoId::from_str(&val) { rid = Some(val); - } else if let Ok(val) = PathBuf::from_str(&val) { - rid = radicle::rad::at(val) + } else { + rid = radicle::rad::at(Path::new(val.as_ref())) .map(|(_, id)| Some(id)) .context("Supplied argument is not a valid path")?; - } else { - return Err(anyhow!("invalid path or RID '{}'", val)); } } _ => return Err(anyhow::anyhow!(arg.unexpected())), diff --git a/radicle-cli/src/commands/seed.rs b/radicle-cli/src/commands/seed.rs index f0b8ec35..507566b2 100644 --- a/radicle-cli/src/commands/seed.rs +++ b/radicle-cli/src/commands/seed.rs @@ -7,7 +7,7 @@ use anyhow::anyhow; use radicle::node::policy; use radicle::node::policy::{Policy, Scope}; use radicle::node::Handle; -use radicle::{prelude::*, storage, Node}; +use radicle::{prelude::*, Node}; use radicle_term::Element as _; use crate::commands::rad_sync as sync; @@ -201,7 +201,6 @@ pub fn seeding(profile: &Profile) -> anyhow::Result<()> { let id = rid.to_string(); let name = storage .repository(rid) - .map_err(storage::RepositoryError::from) .and_then(|repo| repo.project().map(|proj| proj.name().to_string())) .unwrap_or_default(); let scope = policy.scope().unwrap_or_default().to_string(); diff --git a/radicle-cli/src/commands/sync.rs b/radicle-cli/src/commands/sync.rs index 81302ccf..d9db82d7 100644 --- a/radicle-cli/src/commands/sync.rs +++ b/radicle-cli/src/commands/sync.rs @@ -490,7 +490,7 @@ pub fn fetch( if settings .seeds .iter() - .all(|nid| results.get(nid).map_or(false, |r| r.is_success())) + .all(|nid| results.get(nid).is_some_and(|r| r.is_success())) { return Ok(results); } diff --git a/radicle-cli/src/git.rs b/radicle-cli/src/git.rs index ab0f5c6a..16cc8cd9 100644 --- a/radicle-cli/src/git.rs +++ b/radicle-cli/src/git.rs @@ -117,7 +117,7 @@ impl<'a> Deref for Remote<'a> { } } -impl<'a> DerefMut for Remote<'a> { +impl DerefMut for Remote<'_> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.inner } diff --git a/radicle-cli/src/project.rs b/radicle-cli/src/project.rs index 3480c924..37708d13 100644 --- a/radicle-cli/src/project.rs +++ b/radicle-cli/src/project.rs @@ -16,7 +16,7 @@ pub struct SetupRemote<'a> { pub repo: &'a git::Repository, } -impl<'a> SetupRemote<'a> { +impl SetupRemote<'_> { /// Run the setup for the given peer. pub fn run( &self, diff --git a/radicle-cli/src/terminal/format.rs b/radicle-cli/src/terminal/format.rs index bf8f1e5d..5875bcab 100644 --- a/radicle-cli/src/terminal/format.rs +++ b/radicle-cli/src/terminal/format.rs @@ -144,7 +144,7 @@ impl<'a> Identity<'a> { } } -impl<'a> fmt::Display for Identity<'a> { +impl fmt::Display for Identity<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let nid = self.profile.id(); let alias = self.profile.aliases().alias(nid); diff --git a/radicle-cli/src/terminal/patch/timeline.rs b/radicle-cli/src/terminal/patch/timeline.rs index 70931b16..14da594e 100644 --- a/radicle-cli/src/terminal/patch/timeline.rs +++ b/radicle-cli/src/terminal/patch/timeline.rs @@ -276,7 +276,7 @@ enum Update<'a> { Merged { author: Author<'a>, merge: Merge }, } -impl<'a> Update<'a> { +impl Update<'_> { fn timestamp(&self) -> cob::Timestamp { match self { Update::Reviewed { review } => review.timestamp(), diff --git a/radicle-crdt/src/test.rs b/radicle-crdt/src/test.rs index 637a6296..e07d708b 100644 --- a/radicle-crdt/src/test.rs +++ b/radicle-crdt/src/test.rs @@ -10,7 +10,7 @@ pub struct WeightedGenerator<'a, T, C> { ctx: C, } -impl<'a, T, C> Iterator for WeightedGenerator<'a, T, C> { +impl Iterator for WeightedGenerator<'_, T, C> { type Item = T; fn next(&mut self) -> Option { diff --git a/radicle-crypto/src/lib.rs b/radicle-crypto/src/lib.rs index 7b8e2544..5417e342 100644 --- a/radicle-crypto/src/lib.rs +++ b/radicle-crypto/src/lib.rs @@ -402,7 +402,7 @@ impl Deref for PublicKey { } #[cfg(feature = "radicle-git-ext")] -impl<'a> From<&PublicKey> for radicle_git_ext::ref_format::Component<'a> { +impl From<&PublicKey> for radicle_git_ext::ref_format::Component<'_> { fn from(id: &PublicKey) -> Self { use radicle_git_ext::ref_format::{Component, RefString}; let refstr = diff --git a/radicle-fetch/src/git/refs/update.rs b/radicle-fetch/src/git/refs/update.rs index 9bb58f85..e3f54e2e 100644 --- a/radicle-fetch/src/git/refs/update.rs +++ b/radicle-fetch/src/git/refs/update.rs @@ -34,7 +34,7 @@ pub struct Applied<'a> { pub updated: Vec, } -impl<'a> Applied<'a> { +impl Applied<'_> { pub fn append(&mut self, other: &mut Self) { self.rejected.append(&mut other.rejected); self.updated.append(&mut other.updated); diff --git a/radicle-fetch/src/git/repository.rs b/radicle-fetch/src/git/repository.rs index 5d57ae22..806e3e34 100644 --- a/radicle-fetch/src/git/repository.rs +++ b/radicle-fetch/src/git/repository.rs @@ -19,7 +19,7 @@ pub enum Updated<'a> { Rejected(Update<'a>), } -impl<'a> From for Updated<'a> { +impl From for Updated<'_> { fn from(up: RefUpdate) -> Self { Updated::Accepted(up) } @@ -176,13 +176,11 @@ fn direct<'a>( no_ff, } .into()), - Ancestry::Diverged => { - return Err(error::Update::NonFF { - name: name.to_owned(), - new: target, - cur: prev, - }) - } + Ancestry::Diverged => Err(error::Update::NonFF { + name: name.to_owned(), + new: target, + cur: prev, + }), } } None => { diff --git a/radicle-fetch/src/state.rs b/radicle-fetch/src/state.rs index 90a9f203..6e47c02f 100644 --- a/radicle-fetch/src/state.rs +++ b/radicle-fetch/src/state.rs @@ -608,7 +608,7 @@ pub(crate) struct Cached<'a, S> { state: &'a mut FetchState, } -impl<'a, S> Cached<'a, S> { +impl Cached<'_, S> { /// Resolves `refname` to its [`ObjectId`] by first looking at the /// [`FetchState`] and falling back to the [`Handle::refdb`]. pub fn refname_to_id<'b, N>( @@ -656,7 +656,7 @@ impl<'a, S> Cached<'a, S> { } } -impl<'a, S> RemoteRepository for Cached<'a, S> { +impl RemoteRepository for Cached<'_, S> { fn remote(&self, remote: &RemoteId) -> Result { // N.b. this is unused so we just delegate to the underlying // repository for a correct implementation. @@ -676,7 +676,7 @@ impl<'a, S> RemoteRepository for Cached<'a, S> { } } -impl<'a, S> ValidateRepository for Cached<'a, S> { +impl ValidateRepository for Cached<'_, S> { // N.b. we don't verify the `rad/id` of each remote since they may // not have a reference to the COB if they have not interacted // with it. diff --git a/radicle-fetch/src/transport/fetch.rs b/radicle-fetch/src/transport/fetch.rs index 6c383860..f45ba045 100644 --- a/radicle-fetch/src/transport/fetch.rs +++ b/radicle-fetch/src/transport/fetch.rs @@ -108,7 +108,7 @@ pub struct FetchOut { // FIXME: the delegate pattern will be removed in the near future and // we should look at the fetch code being used in gix to see how we // can migrate to the proper form of fetching. -impl<'a> Delegate for &'a mut Fetch { +impl Delegate for &mut Fetch { fn receive_pack( &mut self, input: impl io::BufRead, @@ -134,7 +134,7 @@ impl<'a> Delegate for &'a mut Fetch { } } -impl<'a> DelegateBlocking for &'a mut Fetch { +impl DelegateBlocking for &mut Fetch { fn negotiate( &mut self, _refs: &[handshake::Ref], diff --git a/radicle-node/src/lib.rs b/radicle-node/src/lib.rs index ed47827b..768b3b9a 100644 --- a/radicle-node/src/lib.rs +++ b/radicle-node/src/lib.rs @@ -1,3 +1,8 @@ +// N.b. Rust 1.85 introduced some annoying clippy warnings about using `b""` +// syntax in place of `b''`, but in our cases they were u8 and not [u8] so the +// suggestions did not make sense. +#![allow(clippy::byte_char_slices)] + pub mod bounded; pub mod control; pub mod deserializer; diff --git a/radicle-node/src/wire/frame.rs b/radicle-node/src/wire/frame.rs index e753339d..64c874c1 100644 --- a/radicle-node/src/wire/frame.rs +++ b/radicle-node/src/wire/frame.rs @@ -101,19 +101,19 @@ impl StreamId { /// Create a control identifier. pub fn control(link: Link) -> Self { let link = if link.is_outbound() { 0 } else { 1 }; - Self(VarInt::from((StreamKind::Control as u8) << 1 | link)) + Self(VarInt::from(((StreamKind::Control as u8) << 1) | link)) } /// Create a gossip identifier. pub fn gossip(link: Link) -> Self { let link = if link.is_outbound() { 0 } else { 1 }; - Self(VarInt::from((StreamKind::Gossip as u8) << 1 | link)) + Self(VarInt::from(((StreamKind::Gossip as u8) << 1) | link)) } /// Create a git identifier. pub fn git(link: Link) -> Self { let link = if link.is_outbound() { 0 } else { 1 }; - Self(VarInt::from((StreamKind::Git as u8) << 1 | link)) + Self(VarInt::from(((StreamKind::Git as u8) << 1) | link)) } /// Get the nth identifier while preserving the stream type and initiator. diff --git a/radicle-node/src/wire/varint.rs b/radicle-node/src/wire/varint.rs index ca534bfa..0a27e863 100644 --- a/radicle-node/src/wire/varint.rs +++ b/radicle-node/src/wire/varint.rs @@ -135,11 +135,11 @@ impl Encode for VarInt { if x < 2u64.pow(6) { (x as u8).encode(w) } else if x < 2u64.pow(14) { - (0b01 << 14 | x as u16).encode(w) + ((0b01 << 14) | x as u16).encode(w) } else if x < 2u64.pow(30) { - (0b10 << 30 | x as u32).encode(w) + ((0b10 << 30) | x as u32).encode(w) } else if x < 2u64.pow(62) { - (0b11 << 62 | x).encode(w) + ((0b11 << 62) | x).encode(w) } else { panic!("VarInt::encode: integer overflow"); } diff --git a/radicle-node/src/worker/upload_pack.rs b/radicle-node/src/worker/upload_pack.rs index 1914a31d..788d7376 100644 --- a/radicle-node/src/worker/upload_pack.rs +++ b/radicle-node/src/worker/upload_pack.rs @@ -268,7 +268,7 @@ pub(super) mod pktline { } } - impl<'a, R: io::Read> io::Read for Reader<'a, R> { + impl io::Read for Reader<'_, R> { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.stream.read(buf) } diff --git a/radicle-term/src/ansi/style.rs b/radicle-term/src/ansi/style.rs index 5d4d1ee5..0324835a 100644 --- a/radicle-term/src/ansi/style.rs +++ b/radicle-term/src/ansi/style.rs @@ -72,7 +72,7 @@ impl Iterator for Iter { } /// Represents a set of styling options. -#[repr(packed)] +#[repr(C, packed)] #[derive(Default, Debug, Eq, Ord, PartialOrd, Copy, Clone)] pub struct Style { pub(crate) foreground: Color, diff --git a/radicle-term/src/editor.rs b/radicle-term/src/editor.rs index 3f255b4b..2fc0a514 100644 --- a/radicle-term/src/editor.rs +++ b/radicle-term/src/editor.rs @@ -83,6 +83,7 @@ impl Editor { /// Initialize the file with the provided `content`, as long as the file /// does not already contain anything. + #[allow(clippy::byte_char_slices)] pub fn initial(self, content: impl AsRef<[u8]>) -> io::Result { let content = content.as_ref(); let mut file = fs::OpenOptions::new() diff --git a/radicle-term/src/element.rs b/radicle-term/src/element.rs index 7d87d2d3..78f1db5d 100644 --- a/radicle-term/src/element.rs +++ b/radicle-term/src/element.rs @@ -109,7 +109,7 @@ pub trait Element: fmt::Debug + Send + Sync { } } -impl<'a> Element for Box { +impl Element for Box { fn size(&self, parent: Constraint) -> Size { self.deref().size(parent) } diff --git a/radicle-term/src/hstack.rs b/radicle-term/src/hstack.rs index 7af1a38e..4f51f4c2 100644 --- a/radicle-term/src/hstack.rs +++ b/radicle-term/src/hstack.rs @@ -18,7 +18,7 @@ impl<'a> HStack<'a> { } } -impl<'a> Element for HStack<'a> { +impl Element for HStack<'_> { fn size(&self, parent: Constraint) -> Size { let width = self.elems.iter().map(|c| c.columns(parent)).sum(); let height = self.elems.iter().map(|c| c.rows(parent)).max().unwrap_or(0); diff --git a/radicle-term/src/vstack.rs b/radicle-term/src/vstack.rs index 844ca402..d0006903 100644 --- a/radicle-term/src/vstack.rs +++ b/radicle-term/src/vstack.rs @@ -25,7 +25,7 @@ enum Row<'a> { Dividier, } -impl<'a> Row<'a> { +impl Row<'_> { fn width(&self, c: Constraint) -> usize { match self { Self::Element(e) => e.columns(c), @@ -140,7 +140,7 @@ impl<'a> VStack<'a> { } } -impl<'a> Element for VStack<'a> { +impl Element for VStack<'_> { fn size(&self, parent: Constraint) -> Size { self.outer(parent) } diff --git a/radicle/src/cob/cache.rs b/radicle/src/cob/cache.rs index 1a506c66..4a28431a 100644 --- a/radicle/src/cob/cache.rs +++ b/radicle/src/cob/cache.rs @@ -50,7 +50,7 @@ pub struct MigrateProgress<'a> { pub rows: &'a Progress, } -impl<'a> MigrateProgress<'a> { +impl MigrateProgress<'_> { /// If we're done with the migration. pub fn is_done(&self) -> bool { self.migration.current() == self.migration.total() diff --git a/radicle/src/cob/common.rs b/radicle/src/cob/common.rs index bdc94d30..67f2f3b5 100644 --- a/radicle/src/cob/common.rs +++ b/radicle/src/cob/common.rs @@ -127,7 +127,7 @@ impl<'de> Deserialize<'de> for Reaction { { struct ReactionVisitor; - impl<'de> serde::de::Visitor<'de> for ReactionVisitor { + impl serde::de::Visitor<'_> for ReactionVisitor { type Value = Reaction; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { @@ -316,7 +316,7 @@ impl std::str::FromStr for Uri { type Err = String; fn from_str(s: &str) -> Result { - if !s.chars().all(|c| c.is_ascii()) { + if !s.is_ascii() { return Err(s.to_owned()); } if !s.contains(':') { diff --git a/radicle/src/cob/identity.rs b/radicle/src/cob/identity.rs index 550f7418..bfa8aed8 100644 --- a/radicle/src/cob/identity.rs +++ b/radicle/src/cob/identity.rs @@ -867,7 +867,7 @@ pub struct IdentityMut<'a, R> { store: store::Store<'a, Identity, R>, } -impl<'a, R> fmt::Debug for IdentityMut<'a, R> { +impl fmt::Debug for IdentityMut<'_, R> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("IdentityMut") .field("id", &self.id) @@ -876,7 +876,7 @@ impl<'a, R> fmt::Debug for IdentityMut<'a, R> { } } -impl<'a, R> IdentityMut<'a, R> +impl IdentityMut<'_, R> where R: WriteRepository + cob::Store, { @@ -971,7 +971,7 @@ where } } -impl<'a, R> Deref for IdentityMut<'a, R> { +impl Deref for IdentityMut<'_, R> { type Target = Identity; fn deref(&self) -> &Self::Target { diff --git a/radicle/src/cob/issue.rs b/radicle/src/cob/issue.rs index 348714e6..8c826ed0 100644 --- a/radicle/src/cob/issue.rs +++ b/radicle/src/cob/issue.rs @@ -306,7 +306,7 @@ impl Issue { pub fn replies_to<'a>( &'a self, to: &'a CommentId, - ) -> impl Iterator { + ) -> impl Iterator { self.thread.replies(to) } @@ -576,7 +576,7 @@ pub struct IssueMut<'a, 'g, R, C> { cache: &'g mut C, } -impl<'a, 'g, R, C> std::fmt::Debug for IssueMut<'a, 'g, R, C> { +impl std::fmt::Debug for IssueMut<'_, '_, R, C> { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.debug_struct("IssueMut") .field("id", &self.id) @@ -585,7 +585,7 @@ impl<'a, 'g, R, C> std::fmt::Debug for IssueMut<'a, 'g, R, C> { } } -impl<'a, 'g, R, C> IssueMut<'a, 'g, R, C> +impl IssueMut<'_, '_, R, C> where R: WriteRepository + cob::Store, C: cob::cache::Update, @@ -719,7 +719,7 @@ where } } -impl<'a, 'g, R, C> Deref for IssueMut<'a, 'g, R, C> { +impl Deref for IssueMut<'_, '_, R, C> { type Target = Issue; fn deref(&self) -> &Self::Target { @@ -739,7 +739,7 @@ impl<'a, R> Deref for Issues<'a, R> { } } -impl<'a, R> HasRepoId for Issues<'a, R> +impl HasRepoId for Issues<'_, R> where R: ReadRepository, { diff --git a/radicle/src/cob/issue/cache.rs b/radicle/src/cob/issue/cache.rs index 7b5fac97..915d42a1 100644 --- a/radicle/src/cob/issue/cache.rs +++ b/radicle/src/cob/issue/cache.rs @@ -364,7 +364,7 @@ pub struct NoCacheIter<'a> { inner: Box> + 'a>, } -impl<'a> Iterator for NoCacheIter<'a> { +impl Iterator for NoCacheIter<'_> { type Item = Result<(IssueId, Issue), super::Error>; fn next(&mut self) -> Option { @@ -372,12 +372,15 @@ impl<'a> Iterator for NoCacheIter<'a> { } } -impl<'a, R> Issues for Cache, cache::NoCache> +impl Issues for Cache, cache::NoCache> where R: ReadRepository + cob::Store, { type Error = super::Error; - type Iter<'b> = NoCacheIter<'b> where Self: 'b; + type Iter<'b> + = NoCacheIter<'b> + where + Self: 'b; fn get(&self, id: &IssueId) -> Result, Self::Error> { self.store.get(id).map_err(super::Error::from) @@ -406,7 +409,7 @@ where } fn counts(&self) -> Result { - self.store.counts().map_err(super::Error::from) + self.store.counts() } } @@ -430,7 +433,7 @@ pub struct IssuesIter<'a> { inner: sql::CursorWithOwnership<'a>, } -impl<'a> IssuesIter<'a> { +impl IssuesIter<'_> { fn parse_row(row: sql::Row) -> Result<(IssueId, Issue), Error> { let id = IssueId::from_str(row.read::<&str, _>("id"))?; let issue = serde_json::from_str::(row.read::<&str, _>("issue"))?; @@ -438,7 +441,7 @@ impl<'a> IssuesIter<'a> { } } -impl<'a> Iterator for IssuesIter<'a> { +impl Iterator for IssuesIter<'_> { type Item = Result<(IssueId, Issue), Error>; fn next(&mut self) -> Option { @@ -452,7 +455,10 @@ where R: HasRepoId, { type Error = Error; - type Iter<'b> = IssuesIter<'b> where Self: 'b; + type Iter<'b> + = IssuesIter<'b> + where + Self: 'b; fn get(&self, id: &IssueId) -> Result, Self::Error> { query::get(&self.cache.db, &self.rid(), id) @@ -476,7 +482,10 @@ where R: HasRepoId, { type Error = Error; - type Iter<'b> = IssuesIter<'b> where Self: 'b; + type Iter<'b> + = IssuesIter<'b> + where + Self: 'b; fn get(&self, id: &IssueId) -> Result, Self::Error> { query::get(&self.cache.db, &self.rid(), id) diff --git a/radicle/src/cob/job.rs b/radicle/src/cob/job.rs index 4f0e67f8..961ff487 100644 --- a/radicle/src/cob/job.rs +++ b/radicle/src/cob/job.rs @@ -300,7 +300,7 @@ impl<'a, 'g, R> From> for (JobId, Job) { } } -impl<'a, 'g, R> std::fmt::Debug for JobMut<'a, 'g, R> { +impl std::fmt::Debug for JobMut<'_, '_, R> { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.debug_struct("JobMut") .field("id", &self.id) @@ -309,7 +309,7 @@ impl<'a, 'g, R> std::fmt::Debug for JobMut<'a, 'g, R> { } } -impl<'a, 'g, R> JobMut<'a, 'g, R> +impl JobMut<'_, '_, R> where R: WriteRepository + cob::Store, { @@ -365,7 +365,7 @@ where } } -impl<'a, 'g, R> Deref for JobMut<'a, 'g, R> { +impl Deref for JobMut<'_, '_, R> { type Target = Job; fn deref(&self) -> &Self::Target { diff --git a/radicle/src/cob/patch.rs b/radicle/src/cob/patch.rs index 6425152b..370b54b1 100644 --- a/radicle/src/cob/patch.rs +++ b/radicle/src/cob/patch.rs @@ -332,7 +332,7 @@ pub struct Merged<'a, R> { stored: &'a R, } -impl<'a, R: WriteRepository> Merged<'a, R> { +impl Merged<'_, R> { /// Cleanup after merging a patch. /// /// This removes Git refs relating to the patch, both in the working copy, @@ -521,7 +521,7 @@ impl Patch { pub fn revisions_by<'a>( &'a self, author: &'a PublicKey, - ) -> impl DoubleEndedIterator { + ) -> impl DoubleEndedIterator { self.revisions() .filter(move |(_, r)| (r.author.public_key() == author)) } @@ -569,7 +569,7 @@ impl Patch { /// Get the commit range of this patch. pub fn range(&self) -> Result<(git::Oid, git::Oid), git::ext::Error> { - return Ok((*self.base(), *self.head())); + Ok((*self.base(), *self.head())) } /// Index of latest revision in the revisions list. @@ -596,7 +596,7 @@ impl Patch { } /// Latest revision by the given author. - pub fn latest_by<'a>(&'a self, author: &'a PublicKey) -> Option<(RevisionId, &Revision)> { + pub fn latest_by<'a>(&'a self, author: &'a PublicKey) -> Option<(RevisionId, &'a Revision)> { self.revisions_by(author).next_back() } @@ -2348,7 +2348,7 @@ where } } -impl<'a, 'g, R, C> Deref for PatchMut<'a, 'g, R, C> { +impl Deref for PatchMut<'_, '_, R, C> { type Target = Patch; fn deref(&self) -> &Self::Target { @@ -2396,7 +2396,7 @@ impl<'a, R> Deref for Patches<'a, R> { } } -impl<'a, R> HasRepoId for Patches<'a, R> +impl HasRepoId for Patches<'_, R> where R: ReadRepository, { @@ -2481,7 +2481,7 @@ where pub fn proposed_by<'b>( &'b self, who: &'b Did, - ) -> Result + '_, Error> { + ) -> Result + 'b, Error> { Ok(self .proposed()? .filter(move |(_, p)| p.author().id() == who)) diff --git a/radicle/src/cob/patch/cache.rs b/radicle/src/cob/patch/cache.rs index 16c89f6b..784d1d4a 100644 --- a/radicle/src/cob/patch/cache.rs +++ b/radicle/src/cob/patch/cache.rs @@ -425,7 +425,7 @@ pub struct PatchesIter<'a> { inner: sql::CursorWithOwnership<'a>, } -impl<'a> PatchesIter<'a> { +impl PatchesIter<'_> { fn parse_row(row: sql::Row) -> Result<(PatchId, Patch), Error> { let id = PatchId::from_str(row.read::<&str, _>("id"))?; let patch = serde_json::from_str::(row.read::<&str, _>("patch")) @@ -434,7 +434,7 @@ impl<'a> PatchesIter<'a> { } } -impl<'a> Iterator for PatchesIter<'a> { +impl Iterator for PatchesIter<'_> { type Item = Result<(PatchId, Patch), Error>; fn next(&mut self) -> Option { @@ -448,7 +448,8 @@ where R: HasRepoId, { type Error = Error; - type Iter<'b> = PatchesIter<'b> + type Iter<'b> + = PatchesIter<'b> where Self: 'b; @@ -477,7 +478,7 @@ pub struct NoCacheIter<'a> { inner: Box> + 'a>, } -impl<'a> Iterator for NoCacheIter<'a> { +impl Iterator for NoCacheIter<'_> { type Item = Result<(PatchId, Patch), super::Error>; fn next(&mut self) -> Option { @@ -485,12 +486,15 @@ impl<'a> Iterator for NoCacheIter<'a> { } } -impl<'a, R> Patches for Cache, cache::NoCache> +impl Patches for Cache, cache::NoCache> where R: ReadRepository + cob::Store, { type Error = super::Error; - type Iter<'b> = NoCacheIter<'b> where Self: 'b; + type Iter<'b> + = NoCacheIter<'b> + where + Self: 'b; fn get(&self, id: &PatchId) -> Result, Self::Error> { self.store.get(id).map_err(super::Error::from) @@ -536,7 +540,8 @@ where R: HasRepoId, { type Error = Error; - type Iter<'b> = PatchesIter<'b> + type Iter<'b> + = PatchesIter<'b> where Self: 'b; diff --git a/radicle/src/cob/store.rs b/radicle/src/cob/store.rs index 791e8bae..a66b27e2 100644 --- a/radicle/src/cob/store.rs +++ b/radicle/src/cob/store.rs @@ -111,7 +111,7 @@ pub struct Store<'a, T, R> { witness: PhantomData, } -impl<'a, T, R> AsRef for Store<'a, T, R> { +impl AsRef for Store<'_, T, R> { fn as_ref(&self) -> &R { self.repo } @@ -140,7 +140,7 @@ where } } -impl<'a, T, R> Store<'a, T, R> +impl Store<'_, T, R> where R: ReadRepository + SignRepository + cob::Store, T: Cob + cob::Evaluate, diff --git a/radicle/src/cob/thread.rs b/radicle/src/cob/thread.rs index eca10cdf..a0e814a4 100644 --- a/radicle/src/cob/thread.rs +++ b/radicle/src/cob/thread.rs @@ -387,7 +387,7 @@ impl Thread> { pub fn replies<'a>( &'a self, to: &'a CommentId, - ) -> impl Iterator)> { + ) -> impl Iterator)> { self.comments().filter_map(move |(id, c)| { if let Some(reply_to) = c.reply_to { if &reply_to == to { diff --git a/radicle/src/git/canonical.rs b/radicle/src/git/canonical.rs index c8637b82..cb794bd6 100644 --- a/radicle/src/git/canonical.rs +++ b/radicle/src/git/canonical.rs @@ -200,7 +200,7 @@ impl Canonical { let (mut longest, _) = candidates .pop_first() - .ok_or_else(|| QuorumError::NoCandidates(NoCandidates { threshold }))?; + .ok_or(QuorumError::NoCandidates(NoCandidates { threshold }))?; // Now that all scores are calculated, figure out what is the longest branch // that passes the threshold. In case of divergence, return an error. diff --git a/radicle/src/node.rs b/radicle/src/node.rs index 372159e3..669fa832 100644 --- a/radicle/src/node.rs +++ b/radicle/src/node.rs @@ -757,7 +757,7 @@ impl Seeds { /// Check if a seed is connected. pub fn is_connected(&self, nid: &NodeId) -> bool { - self.0.get(nid).map_or(false, |s| s.is_connected()) + self.0.get(nid).is_some_and(|s| s.is_connected()) } /// Return a new seeds object with the given RNG. @@ -1197,14 +1197,12 @@ impl Handle for Node { self.call::(Command::NodeId, DEFAULT_TIMEOUT)? .next() .ok_or(Error::EmptyResponse)? - .map_err(Error::from) } fn listen_addrs(&self) -> Result, Error> { self.call::>(Command::ListenAddrs, DEFAULT_TIMEOUT)? .next() .ok_or(Error::EmptyResponse)? - .map_err(Error::from) } fn is_running(&self) -> bool { @@ -1222,7 +1220,6 @@ impl Handle for Node { self.call::(Command::Config, DEFAULT_TIMEOUT)? .next() .ok_or(Error::EmptyResponse)? - .map_err(Error::from) } fn connect( diff --git a/radicle/src/node/address/store.rs b/radicle/src/node/address/store.rs index b10b2187..e2b5aa2b 100644 --- a/radicle/src/node/address/store.rs +++ b/radicle/src/node/address/store.rs @@ -428,7 +428,7 @@ pub struct NodeAliasIter<'a> { inner: sql::CursorWithOwnership<'a>, } -impl<'a> NodeAliasIter<'a> { +impl NodeAliasIter<'_> { fn parse_row(row: sql::Row) -> Result<(NodeId, Alias), Error> { let nid = row.try_read::("id")?; let alias = row.try_read::<&str, _>("alias")?.parse()?; @@ -436,7 +436,7 @@ impl<'a> NodeAliasIter<'a> { } } -impl<'a> Iterator for NodeAliasIter<'a> { +impl Iterator for NodeAliasIter<'_> { type Item = Result<(NodeId, Alias), Error>; fn next(&mut self) -> Option { @@ -446,7 +446,8 @@ impl<'a> Iterator for NodeAliasIter<'a> { } impl StoreExt for Database { - type NodeAlias<'a> = NodeAliasIter<'a> + type NodeAlias<'a> + = NodeAliasIter<'a> where Self: 'a; diff --git a/radicle/src/node/notifications.rs b/radicle/src/node/notifications.rs index cbea534a..23f77d9b 100644 --- a/radicle/src/node/notifications.rs +++ b/radicle/src/node/notifications.rs @@ -76,7 +76,7 @@ pub enum NotificationKindError { RefFormat(#[from] radicle_git_ext::ref_format::Error), } -impl<'a> TryFrom> for NotificationKind { +impl TryFrom> for NotificationKind { type Error = NotificationKindError; fn try_from(value: Qualified) -> Result { diff --git a/radicle/src/node/policy/store.rs b/radicle/src/node/policy/store.rs index 6588581b..ce881a95 100644 --- a/radicle/src/node/policy/store.rs +++ b/radicle/src/node/policy/store.rs @@ -328,7 +328,7 @@ pub struct FollowPolicies<'a> { inner: sql::CursorWithOwnership<'a>, } -impl<'a> Iterator for FollowPolicies<'a> { +impl Iterator for FollowPolicies<'_> { type Item = FollowPolicy; fn next(&mut self) -> Option { @@ -355,7 +355,7 @@ pub struct SeedPolicies<'a> { inner: sql::CursorWithOwnership<'a>, } -impl<'a> Iterator for SeedPolicies<'a> { +impl Iterator for SeedPolicies<'_> { type Item = SeedPolicy; fn next(&mut self) -> Option { @@ -376,7 +376,7 @@ pub struct NodeAliasIter<'a> { inner: sql::CursorWithOwnership<'a>, } -impl<'a> NodeAliasIter<'a> { +impl NodeAliasIter<'_> { fn parse_row(row: sql::Row) -> Result<(NodeId, Alias), Error> { let nid = row.try_read::("id")?; let alias = row.try_read::("alias")?; @@ -384,7 +384,7 @@ impl<'a> NodeAliasIter<'a> { } } -impl<'a> Iterator for NodeAliasIter<'a> { +impl Iterator for NodeAliasIter<'_> { type Item = Result<(NodeId, Alias), Error>; fn next(&mut self) -> Option { diff --git a/radicle/src/storage/git.rs b/radicle/src/storage/git.rs index b0e3aae1..758874be 100644 --- a/radicle/src/storage/git.rs +++ b/radicle/src/storage/git.rs @@ -52,7 +52,7 @@ pub struct Ref { pub namespace: Option, } -impl<'a> TryFrom> for Ref { +impl TryFrom> for Ref { type Error = RefError; fn try_from(r: git2::Reference) -> Result { diff --git a/radicle/src/storage/git/cob.rs b/radicle/src/storage/git/cob.rs index b3e1cc58..ea24fab7 100644 --- a/radicle/src/storage/git/cob.rs +++ b/radicle/src/storage/git/cob.rs @@ -170,7 +170,7 @@ impl cob::object::Storage for Repository { .backend .find_reference(git::refs::storage::cob(identifier, typename, object_id).as_str())?; - reference.delete().map_err(Self::RemoveError::from) + reference.delete() } } @@ -190,9 +190,9 @@ impl<'a, R> DraftStore<'a, R> { } } -impl<'a, R: storage::WriteRepository> cob::Store for DraftStore<'a, R> {} +impl cob::Store for DraftStore<'_, R> {} -impl<'a, R: storage::WriteRepository> change::Storage for DraftStore<'a, R> { +impl change::Storage for DraftStore<'_, R> { type StoreError = ::StoreError; type LoadError = ::LoadError; @@ -222,7 +222,7 @@ impl<'a, R: storage::WriteRepository> change::Storage for DraftStore<'a, R> { } } -impl<'a, R: storage::ReadRepository> SignRepository for DraftStore<'a, R> { +impl SignRepository for DraftStore<'_, R> { fn sign_refs( &self, signer: &G, @@ -235,7 +235,7 @@ impl<'a, R: storage::ReadRepository> SignRepository for DraftStore<'a, R> { } } -impl<'a, R: storage::RemoteRepository> RemoteRepository for DraftStore<'a, R> { +impl RemoteRepository for DraftStore<'_, R> { fn remote(&self, id: &RemoteId) -> Result, storage::refs::Error> { self.repo.remote(id) } @@ -249,13 +249,13 @@ impl<'a, R: storage::RemoteRepository> RemoteRepository for DraftStore<'a, R> { } } -impl<'a, R: storage::ValidateRepository> ValidateRepository for DraftStore<'a, R> { +impl ValidateRepository for DraftStore<'_, R> { fn validate_remote(&self, remote: &Remote) -> Result { self.repo.validate_remote(remote) } } -impl<'a, R: storage::ReadRepository> ReadRepository for DraftStore<'a, R> { +impl ReadRepository for DraftStore<'_, R> { fn id(&self) -> identity::RepoId { self.repo.id() } @@ -364,7 +364,7 @@ impl<'a, R: storage::ReadRepository> ReadRepository for DraftStore<'a, R> { } } -impl<'a, R: storage::WriteRepository> cob::object::Storage for DraftStore<'a, R> { +impl cob::object::Storage for DraftStore<'_, R> { type ObjectsError = ObjectsError; type TypesError = git::ext::Error; type UpdateError = git2::Error; diff --git a/radicle/src/version.rs b/radicle/src/version.rs index 2d2eff51..b390e10b 100644 --- a/radicle/src/version.rs +++ b/radicle/src/version.rs @@ -10,7 +10,7 @@ pub struct Version<'a> { pub timestamp: &'a str, } -impl<'a> Version<'a> { +impl Version<'_> { /// Write program version as string. /// Adjust with caution, third party applications parse the string for version info. pub fn write(&self, mut w: impl std::io::Write) -> Result<(), io::Error> { diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 96b30271..4b45ca89 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.80" +channel = "1.85" profile = "default" components = [ "rust-src" ]