From f26674a5a9745b3e11fd297a5a2fbfdbb1d49904 Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Thu, 15 Dec 2022 19:25:47 +0100 Subject: [PATCH] Upgrade Rust to 1.66 Signed-off-by: Alexis Sellier --- .github/workflows/actions.yml | 4 ++-- radicle-cli/src/commands/auth.rs | 4 ++-- radicle-cli/src/commands/checkout.rs | 2 +- radicle-cli/src/commands/init.rs | 6 +++--- radicle-cli/src/commands/inspect.rs | 2 +- radicle-cli/src/commands/patch/create.rs | 10 +++++----- radicle-cli/src/commands/patch/list.rs | 8 ++++---- radicle-cli/src/commands/push.rs | 4 ++-- radicle-cli/src/commands/rm.rs | 2 +- radicle-cli/src/commands/track.rs | 4 ++-- radicle-cli/src/main.rs | 2 +- radicle-cli/src/terminal/table.rs | 18 ++++++++++-------- radicle-crypto/src/test/arbitrary.rs | 2 +- radicle-node/src/address/store.rs | 2 +- radicle-node/src/service/message.rs | 2 +- radicle-node/src/wire.rs | 5 +---- radicle-remote-helper/src/lib.rs | 2 +- radicle-tools/src/rad-push.rs | 2 +- radicle/src/profile.rs | 4 ++-- radicle/src/rad.rs | 2 +- radicle/src/storage/git.rs | 2 +- radicle/src/storage/refs.rs | 4 ++-- rust-toolchain | 2 +- 23 files changed, 47 insertions(+), 48 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index e7b0b2e3..d14823f7 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -15,7 +15,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.65 + toolchain: 1.66 - name: Build run: cargo build --verbose --all-features env: @@ -43,7 +43,7 @@ jobs: with: profile: minimal components: clippy, rustfmt - toolchain: 1.65 + toolchain: 1.66 - name: Cache cargo registry uses: actions/cache@v1 with: diff --git a/radicle-cli/src/commands/auth.rs b/radicle-cli/src/commands/auth.rs index 70e1ad9b..4bb5de1a 100644 --- a/radicle-cli/src/commands/auth.rs +++ b/radicle-cli/src/commands/auth.rs @@ -85,13 +85,13 @@ pub fn init(options: Options) -> anyhow::Result<()> { term::success!( "Profile {} created.", - term::format::highlight(&profile.id().to_string()) + term::format::highlight(profile.id().to_string()) ); term::blank(); term::info!( "Your radicle Node ID is {}. This identifies your device.", - term::format::highlight(&profile.id().to_string()) + term::format::highlight(profile.id().to_string()) ); term::blank(); diff --git a/radicle-cli/src/commands/checkout.rs b/radicle-cli/src/commands/checkout.rs index cf3ad749..6adb1eec 100644 --- a/radicle-cli/src/commands/checkout.rs +++ b/radicle-cli/src/commands/checkout.rs @@ -139,7 +139,7 @@ pub fn setup_remotes(setup: project::SetupRemote, remotes: &[NodeId]) -> anyhow: term::success!("Remote {} set", term::format::highlight(remote)); term::success!( "Remote-tracking branch {} created for {}", - term::format::highlight(&branch), + term::format::highlight(branch), term::format::tertiary(term::format::node(remote_id)) ); } diff --git a/radicle-cli/src/commands/init.rs b/radicle-cli/src/commands/init.rs index 99287076..b0bfb9e6 100644 --- a/radicle-cli/src/commands/init.rs +++ b/radicle-cli/src/commands/init.rs @@ -155,7 +155,7 @@ pub fn init(options: Options, profile: &profile::Profile) -> anyhow::Result<()> if path == cwd { term::format::highlight(".") } else { - term::format::highlight(&path.display()) + term::format::highlight(path.display()) } )); @@ -271,7 +271,7 @@ pub fn setup_signing( )); true } else if interactive.yes() { - term::confirm(&format!( + term::confirm(format!( "Configure 🌱 signing key {} in local checkout?", term::format::tertiary(key), )) @@ -296,7 +296,7 @@ pub fn setup_signing( if ssh_keys.contains(&ssh_key) { term::success!("Signing key is already in {} file", gitsigners); - } else if term::confirm(&format!("Add signing key to {}?", gitsigners)) { + } else if term::confirm(format!("Add signing key to {}?", gitsigners)) { git::add_gitsigners(repo, [node_id])?; } } diff --git a/radicle-cli/src/commands/inspect.rs b/radicle-cli/src/commands/inspect.rs index ced20b8c..aadde067 100644 --- a/radicle-cli/src/commands/inspect.rs +++ b/radicle-cli/src/commands/inspect.rs @@ -150,7 +150,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { let repo = storage.repository(id)?; let head = Doc::::head(signer.public_key(), &repo)?; let history = repo.revwalk(head)?.collect::>(); - let revision = history.len() as usize; + let revision = history.len(); for (counter, oid) in history.into_iter().rev().enumerate() { let oid = oid?.into(); diff --git a/radicle-cli/src/commands/patch/create.rs b/radicle-cli/src/commands/patch/create.rs index a4c15e34..bf5ae983 100644 --- a/radicle-cli/src/commands/patch/create.rs +++ b/radicle-cli/src/commands/patch/create.rs @@ -177,11 +177,11 @@ pub fn run( term::info!( "{}/{} ({}) <- {}/{} ({})", term::format::dim(target_peer.id), - term::format::highlight(&project.default_branch.to_string()), - term::format::secondary(&term::format::oid(*target_oid)), + term::format::highlight(project.default_branch.to_string()), + term::format::secondary(term::format::oid(*target_oid)), term::format::dim(term::format::node(patches.public_key())), - term::format::highlight(&head_branch.to_string()), - term::format::secondary(&term::format::oid(head_oid)), + term::format::highlight(head_branch.to_string()), + term::format::secondary(term::format::oid(head_oid)), ); // TODO: Test case where the target branch has been re-written passed the merge-base, since the fork was created @@ -223,7 +223,7 @@ pub fn run( } term::blank(); - term::print(&term::format::dim(format!( + term::print(term::format::dim(format!( "╰{}", "─".repeat(term::text_width(title_pretty) - 1) ))); diff --git a/radicle-cli/src/commands/patch/list.rs b/radicle-cli/src/commands/patch/list.rs index d004ce07..bef975ab 100644 --- a/radicle-cli/src/commands/patch/list.rs +++ b/radicle-cli/src/commands/patch/list.rs @@ -39,11 +39,11 @@ pub fn run( } } term::blank(); - term::print(&term::format::badge_positive("YOU PROPOSED")); + term::print(term::format::badge_positive("YOU PROPOSED")); if own.is_empty() { term::blank(); - term::print(&term::format::italic("Nothing to show.")); + term::print(term::format::italic("Nothing to show.")); } else { for (id, patch) in &mut own { term::blank(); @@ -52,11 +52,11 @@ pub fn run( } } term::blank(); - term::print(&term::format::badge_secondary("OTHERS PROPOSED")); + term::print(term::format::badge_secondary("OTHERS PROPOSED")); if other.is_empty() { term::blank(); - term::print(&term::format::italic("Nothing to show.")); + term::print(term::format::italic("Nothing to show.")); } else { for (id, patch) in &mut other { term::blank(); diff --git a/radicle-cli/src/commands/push.rs b/radicle-cli/src/commands/push.rs index 0239f896..85c65f24 100644 --- a/radicle-cli/src/commands/push.rs +++ b/radicle-cli/src/commands/push.rs @@ -122,10 +122,10 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { } args.push("rad"); // Push to "rad" remote. - term::subcommand(&format!("git {}", args.join(" "))); + term::subcommand(format!("git {}", args.join(" "))); // Push to storage. - match git::run::<_, _, &str, &str>(&cwd, args, []) { + match git::run::<_, _, &str, &str>(cwd, args, []) { Ok(output) => term::blob(output), Err(err) => return Err(err.into()), } diff --git a/radicle-cli/src/commands/rm.rs b/radicle-cli/src/commands/rm.rs index f8a2e253..96e4691d 100644 --- a/radicle-cli/src/commands/rm.rs +++ b/radicle-cli/src/commands/rm.rs @@ -81,7 +81,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { let id = options.id; if let Ok(Some(_)) = storage.get(signer.public_key(), id.to_owned()) { - let namespace = profile.paths().storage().join(&id.to_human()); + let namespace = profile.paths().storage().join(id.to_human()); if !options.confirm || term::confirm(format!( diff --git a/radicle-cli/src/commands/track.rs b/radicle-cli/src/commands/track.rs index 4b07c0d4..ac9a7ece 100644 --- a/radicle-cli/src/commands/track.rs +++ b/radicle-cli/src/commands/track.rs @@ -94,11 +94,11 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { let storage = &profile.storage; let (_, rid) = radicle::rad::cwd().context("this command must be run within a project")?; let project = storage.repository(rid)?.project_of(profile.id())?; - let mut node = radicle::node::connect(&profile.node())?; + let mut node = radicle::node::connect(profile.node())?; term::info!( "Establishing 🌱 tracking relationship for {}", - term::format::highlight(&project.name) + term::format::highlight(project.name) ); term::blank(); diff --git a/radicle-cli/src/main.rs b/radicle-cli/src/main.rs index a1b66cfe..6d357f08 100644 --- a/radicle-cli/src/main.rs +++ b/radicle-cli/src/main.rs @@ -23,7 +23,7 @@ fn main() { Ok(_) => process::exit(0), Err(err) => { if let Some(err) = err { - term::error(&format!("Error: rad: {}", err)); + term::error(format!("Error: rad: {}", err)); } process::exit(1); } diff --git a/radicle-cli/src/terminal/table.rs b/radicle-cli/src/terminal/table.rs index 91ffacf4..ad381af2 100644 --- a/radicle-cli/src/terminal/table.rs +++ b/radicle-cli/src/terminal/table.rs @@ -14,6 +14,16 @@ pub struct Table { opts: TableOptions, } +impl Default for Table { + fn default() -> Self { + Self { + rows: Vec::new(), + widths: [0; W], + opts: TableOptions::default(), + } + } +} + impl Table { pub fn new(opts: TableOptions) -> Self { Self { @@ -23,14 +33,6 @@ impl Table { } } - pub fn default() -> Self { - Self { - rows: Vec::new(), - widths: [0; W], - opts: TableOptions::default(), - } - } - pub fn push(&mut self, row: [String; W]) { for (i, cell) in row.iter().enumerate() { self.widths[i] = self.widths[i].max(console::measure_text_width(cell)); diff --git a/radicle-crypto/src/test/arbitrary.rs b/radicle-crypto/src/test/arbitrary.rs index 9ddc92e9..cb5e1872 100644 --- a/radicle-crypto/src/test/arbitrary.rs +++ b/radicle-crypto/src/test/arbitrary.rs @@ -25,6 +25,6 @@ impl Arbitrary for PublicKey { impl Arbitrary for hash::Digest { fn arbitrary(g: &mut qcheck::Gen) -> Self { let bytes: Vec = Arbitrary::arbitrary(g); - hash::Digest::new(&bytes) + hash::Digest::new(bytes) } } diff --git a/radicle-node/src/address/store.rs b/radicle-node/src/address/store.rs index 55c85089..bb15206f 100644 --- a/radicle-node/src/address/store.rs +++ b/radicle-node/src/address/store.rs @@ -326,7 +326,7 @@ mod test { fn test_empty() { let tmp = tempfile::tempdir().unwrap(); let path = tmp.path().join("cache"); - let cache = Book::open(&path).unwrap(); + let cache = Book::open(path).unwrap(); assert!(cache.is_empty().unwrap()); } diff --git a/radicle-node/src/service/message.rs b/radicle-node/src/service/message.rs index 7e795f0f..db958d5c 100644 --- a/radicle-node/src/service/message.rs +++ b/radicle-node/src/service/message.rs @@ -294,7 +294,7 @@ impl Announcement { /// Verify this announcement's signature. pub fn verify(&self) -> bool { let msg = wire::serialize(&self.message); - self.node.verify(&msg, &self.signature).is_ok() + self.node.verify(msg, &self.signature).is_ok() } pub fn matches(&self, filter: &Filter) -> bool { diff --git a/radicle-node/src/wire.rs b/radicle-node/src/wire.rs index b495d1a9..403022bb 100644 --- a/radicle-node/src/wire.rs +++ b/radicle-node/src/wire.rs @@ -126,10 +126,7 @@ impl Encode for PublicKey { impl Encode for &[u8; T] { fn encode(&self, writer: &mut W) -> Result { - // TODO: This can be removed when the clippy bugs are fixed - #[allow(clippy::explicit_auto_deref)] - writer.write_all(*self)?; - + writer.write_all(&**self)?; Ok(mem::size_of::()) } } diff --git a/radicle-remote-helper/src/lib.rs b/radicle-remote-helper/src/lib.rs index 89ea2b9c..c81258af 100644 --- a/radicle-remote-helper/src/lib.rs +++ b/radicle-remote-helper/src/lib.rs @@ -108,7 +108,7 @@ pub fn run(profile: radicle::Profile) -> Result<(), Box anyhow::Result<()> { let sigrefs = project.sign_refs(&signer)?; let head = project.set_head()?; - radicle::node::connect(&profile.node())?.announce_refs(id)?; + radicle::node::connect(profile.node())?.announce_refs(id)?; println!("head: {}", head); println!("ok: {}", sigrefs.signature); diff --git a/radicle/src/profile.rs b/radicle/src/profile.rs index 6020fdca..ef775250 100644 --- a/radicle/src/profile.rs +++ b/radicle/src/profile.rs @@ -59,7 +59,7 @@ pub struct Profile { impl Profile { pub fn init(home: impl AsRef, passphrase: &str) -> Result { let home = home.as_ref().to_path_buf(); - let storage = Storage::open(&home.join("storage"))?; + let storage = Storage::open(home.join("storage"))?; let keystore = Keystore::new(&home.join("keys")); let public_key = keystore.init("radicle", passphrase)?; @@ -75,7 +75,7 @@ impl Profile { pub fn load() -> Result { let home = self::home()?; - let storage = Storage::open(&home.join("storage"))?; + let storage = Storage::open(home.join("storage"))?; let keystore = Keystore::new(&home.join("keys")); let public_key = keystore .public_key()? diff --git a/radicle/src/rad.rs b/radicle/src/rad.rs index 58453202..c843088b 100644 --- a/radicle/src/rad.rs +++ b/radicle/src/rad.rs @@ -392,7 +392,7 @@ mod tests { let (_, head) = project_repo.head().unwrap(); // Test canonical refs. - assert_eq!(refs.head(&component!("master")).unwrap(), head); + assert_eq!(refs.head(component!("master")).unwrap(), head); assert_eq!(project_repo.raw().refname_to_id("HEAD").unwrap(), *head); assert_eq!( project_repo diff --git a/radicle/src/storage/git.rs b/radicle/src/storage/git.rs index 94fc5606..c53d467d 100644 --- a/radicle/src/storage/git.rs +++ b/radicle/src/storage/git.rs @@ -1059,7 +1059,7 @@ mod tests { let addr = socket.local_addr().unwrap(); let source_path = tmp.path().join("source"); let target_path = tmp.path().join("target"); - let (source, _) = fixtures::repository(&source_path); + let (source, _) = fixtures::repository(source_path); transport::local::register(storage.clone()); diff --git a/radicle/src/storage/refs.rs b/radicle/src/storage/refs.rs index 1cea381d..ca59a7d5 100644 --- a/radicle/src/storage/refs.rs +++ b/radicle/src/storage/refs.rs @@ -76,7 +76,7 @@ impl Refs { let refs = self; let msg = refs.canonical(); - match signer.verify(&msg, &signature) { + match signer.verify(msg, &signature) { Ok(()) => Ok(SignedRefs { refs, signature, @@ -230,7 +230,7 @@ impl SignedRefs { pub fn verify(&self, signer: &PublicKey) -> Result<(), crypto::Error> { let canonical = self.refs.canonical(); - match signer.verify(&canonical, &self.signature) { + match signer.verify(canonical, &self.signature) { Ok(()) => Ok(()), Err(e) => Err(e), } diff --git a/rust-toolchain b/rust-toolchain index 5b6cd6b3..9cf4011b 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.65 +1.66