From 3f48c2c516797cf5c174fc266e2263a07f04f567 Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Fri, 3 Feb 2023 13:43:30 +0000 Subject: [PATCH] Rust 1.67 Rust 1.67 was announced[0]. Update the necessary files for running 1.67 and fix the clippy suggestions for string interpolation. [0]: https://blog.rust-lang.org/2023/01/26/Rust-1.67.0.html Signed-off-by: Fintan Halpenny X-Clacks-Overhead: GNU Terry Pratchett --- .github/workflows/ci.yaml | 4 ++-- .nix/sources.json | 12 +++++------ build.rs | 2 +- radicle-cli/src/commands/checkout.rs | 2 +- radicle-cli/src/commands/init.rs | 4 ++-- radicle-cli/src/commands/inspect.rs | 4 ++-- radicle-cli/src/commands/merge.rs | 10 ++++----- radicle-cli/src/commands/patch/common.rs | 4 ++-- radicle-cli/src/commands/patch/create.rs | 4 ++-- radicle-cli/src/commands/patch/show.rs | 4 ++-- radicle-cli/src/commands/review.rs | 6 +++--- radicle-cli/src/git.rs | 2 +- radicle-cli/src/main.rs | 10 ++++----- radicle-cli/src/terminal.rs | 2 +- radicle-cli/src/terminal/args.rs | 4 ++-- radicle-cli/src/terminal/format.rs | 15 ++++++------- radicle-cli/src/terminal/io.rs | 24 +++++++++------------ radicle-cli/src/terminal/patch.rs | 2 +- radicle-cli/src/terminal/table.rs | 2 +- radicle-cob/src/test/identity/person.rs | 2 +- radicle-cob/src/test/identity/project.rs | 2 +- radicle-cob/src/test/storage.rs | 4 ++-- radicle-crypto/src/hash.rs | 4 ++-- radicle-crypto/src/lib.rs | 4 ++-- radicle-crypto/src/ssh.rs | 2 +- radicle-dag/src/lib.rs | 4 ++-- radicle-httpd/src/api/axum_extra.rs | 4 ++-- radicle-httpd/src/lib.rs | 2 +- radicle-node/src/control.rs | 17 +++++++-------- radicle-node/src/logger.rs | 2 +- radicle-node/src/service.rs | 22 +++++++++---------- radicle-node/src/service/message.rs | 8 +++---- radicle-node/src/test/logger.rs | 4 ++-- radicle-node/src/test/simulator.rs | 5 +---- radicle-node/src/tests/e2e.rs | 8 +++---- radicle-node/src/wire/protocol.rs | 6 +++--- radicle-remote-helper/src/git-remote-rad.rs | 4 ++-- radicle-tools/src/rad-init.rs | 2 +- radicle-tools/src/rad-push.rs | 4 ++-- radicle/src/git.rs | 4 ++-- radicle/src/identity.rs | 4 ++-- radicle/src/identity/doc/id.rs | 2 +- radicle/src/storage.rs | 8 +++---- radicle/src/storage/git.rs | 4 ++-- radicle/src/storage/refs.rs | 2 +- rust-toolchain | 2 +- 46 files changed, 121 insertions(+), 132 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e02fe76a..a2fd240a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@1.66 + - uses: dtolnay/rust-toolchain@1.67 - run: cargo build --all-features env: RUSTFLAGS: -D warnings @@ -35,7 +35,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@1.66 + - uses: dtolnay/rust-toolchain@1.67 - run: cargo doc --all --all-features env: RUSTDOCFLAGS: -D warnings diff --git a/.nix/sources.json b/.nix/sources.json index 53ebb729..64d1605a 100644 --- a/.nix/sources.json +++ b/.nix/sources.json @@ -5,10 +5,10 @@ "homepage": "https://github.com/nmattia/niv", "owner": "nmattia", "repo": "niv", - "rev": "351d8bc316bf901a81885bab5f52687ec8ccab6e", - "sha256": "1yzhz7ihkh6p2sxhp3amqfbmm2yqzaadqqii1xijymvl8alw5rrr", + "rev": "689d0e5539eddd0b0f566aee7bb18629eee7df74", + "sha256": "1rld3lk42l6b01f2gcrhq8qm9vry1awmfl29zmpiqda9dy89vbx0", "type": "tarball", - "url": "https://github.com/nmattia/niv/archive/351d8bc316bf901a81885bab5f52687ec8ccab6e.tar.gz", + "url": "https://github.com/nmattia/niv/archive/689d0e5539eddd0b0f566aee7bb18629eee7df74.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "nixpkgs": { @@ -29,10 +29,10 @@ "homepage": "", "owner": "oxalica", "repo": "rust-overlay", - "rev": "7da2f6b3a0c32f661cb2864d7fbd1d7e6f0c7543", - "sha256": "1daw246p4aimvx9h3cf034dsyimh9d2ww19v4fx45mcmlqw1mx42", + "rev": "383a4acfd11d778d5c2efcf28376cbd845eeaedf", + "sha256": "1p1vcmfwhi6397xb4bq95dsc185mf2wg8jw8wv51kn3n1xkwlh5s", "type": "tarball", - "url": "https://github.com/oxalica/rust-overlay/archive/7da2f6b3a0c32f661cb2864d7fbd1d7e6f0c7543.tar.gz", + "url": "https://github.com/oxalica/rust-overlay/archive/383a4acfd11d778d5c2efcf28376cbd845eeaedf.tar.gz", "url_template": "https://github.com///archive/.tar.gz" } } diff --git a/build.rs b/build.rs index fc6352c2..ddda179f 100644 --- a/build.rs +++ b/build.rs @@ -18,6 +18,6 @@ fn main() { }) .unwrap_or_else(|| String::from("unknown")); - println!("cargo:rustc-env=GIT_HEAD={}", hash); + println!("cargo:rustc-env=GIT_HEAD={hash}"); println!("cargo:rustc-rerun-if-changed=.git/HEAD"); } diff --git a/radicle-cli/src/commands/checkout.rs b/radicle-cli/src/commands/checkout.rs index c59fac8f..74e7823d 100644 --- a/radicle-cli/src/commands/checkout.rs +++ b/radicle-cli/src/commands/checkout.rs @@ -62,7 +62,7 @@ impl Args for Options { } Value(val) if id.is_none() => { let val = val.to_string_lossy(); - let val = Id::from_str(&val).context(format!("invalid id '{}'", val))?; + let val = Id::from_str(&val).context(format!("invalid id '{val}'"))?; id = Some(val); } diff --git a/radicle-cli/src/commands/init.rs b/radicle-cli/src/commands/init.rs index dca3c9b4..9f07d17d 100644 --- a/radicle-cli/src/commands/init.rs +++ b/radicle-cli/src/commands/init.rs @@ -288,8 +288,8 @@ pub fn setup_signing( git::read_gitsigners(repo).context("error reading .gitsigners file")?; 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)) { + term::success!("Signing key is already in {gitsigners} file"); + } 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 4fa79fbd..d3658081 100644 --- a/radicle-cli/src/commands/inspect.rs +++ b/radicle-cli/src/commands/inspect.rs @@ -175,10 +175,10 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { term::format::yellow(oid), ); if let Ok(parent) = tip.parent_id(0) { - println!("parent {}", parent); + println!("parent {parent}"); } println!("blob {}", blob.id()); - println!("date {}", time); + println!("date {time}"); println!(); if let Some(msg) = tip.message() { diff --git a/radicle-cli/src/commands/merge.rs b/radicle-cli/src/commands/merge.rs index 52c7c304..9f2ac1e5 100644 --- a/radicle-cli/src/commands/merge.rs +++ b/radicle-cli/src/commands/merge.rs @@ -138,7 +138,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { let repository = profile.storage.repository(id)?; let _project = repository .identity_of(profile.id()) - .context(format!("couldn't load project {} from local state", id))?; + .context(format!("couldn't load project {id} from local state"))?; let repository = profile.storage.repository(id)?; let mut patches = Patches::open(*profile.id(), &repository)?; @@ -232,7 +232,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { "{} {} {} ({}) by {} into {} ({}) via {}...", term::format::bold("Merging"), term::format::tertiary(term::format::cob(&patch_id)), - term::format::dim(format!("R{}", revision_ix)), + term::format::dim(format!("R{revision_ix}")), term::format::secondary(term::format::oid(revision.oid)), term::format::tertiary(patch.author().id), term::format::highlight(branch), @@ -302,12 +302,12 @@ fn merge_commit( write!(&mut merge_msg, "\n\n")?; if !description.is_empty() { - write!(&mut merge_msg, "{}", description)?; + write!(&mut merge_msg, "{description}")?; write!(&mut merge_msg, "\n\n")?; } - writeln!(&mut merge_msg, "Rad-Patch: {}", patch_id)?; + writeln!(&mut merge_msg, "Rad-Patch: {patch_id}")?; writeln!(&mut merge_msg, "Rad-Author: {}", patch.author().id())?; - writeln!(&mut merge_msg, "Rad-Committer: {}", whoami)?; + writeln!(&mut merge_msg, "Rad-Committer: {whoami}")?; writeln!(&mut merge_msg)?; writeln!(&mut merge_msg, "{}", MERGE_HELP_MSG.trim())?; diff --git a/radicle-cli/src/commands/patch/common.rs b/radicle-cli/src/commands/patch/common.rs index ad184b78..322ffbed 100644 --- a/radicle-cli/src/commands/patch/common.rs +++ b/radicle-cli/src/commands/patch/common.rs @@ -70,7 +70,7 @@ pub fn pretty_sync_status( let ahead = term::format::positive(a); let behind = term::format::negative(b); - Ok(format!("ahead {}, behind {}", ahead, behind)) + Ok(format!("ahead {ahead}, behind {behind}")) } /// Make a human friendly string for commit version information. @@ -143,7 +143,7 @@ pub fn patch_commits<'a>( ) -> anyhow::Result>> { let mut commits = Vec::new(); let mut revwalk = repo.revwalk()?; - revwalk.push_range(&format!("{}..{}", base, head))?; + revwalk.push_range(&format!("{base}..{head}"))?; for rev in revwalk { let commit = repo.find_commit(rev?)?; diff --git a/radicle-cli/src/commands/patch/create.rs b/radicle-cli/src/commands/patch/create.rs index 5efb0313..30e986f1 100644 --- a/radicle-cli/src/commands/patch/create.rs +++ b/radicle-cli/src/commands/patch/create.rs @@ -229,7 +229,7 @@ pub fn run( let commit_message = head_commit .message() .ok_or(anyhow!("commit summary is not valid UTF-8; aborting"))?; - let message = message.get(&format!("{}{}", commit_message, PATCH_MSG)); + let message = message.get(&format!("{commit_message}{PATCH_MSG}")); let (title, description) = message.split_once("\n\n").unwrap_or((&message, "")); let (title, description) = (title.trim(), description.trim()); let description = description.replace(PATCH_MSG.trim(), ""); // Delete help message. @@ -289,7 +289,7 @@ fn update( term::info!( "{} {} ({}) -> {} ({})", term::format::tertiary(term::format::cob(&patch_id)), - term::format::dim(format!("R{}", current_version)), + term::format::dim(format!("R{current_version}")), term::format::secondary(term::format::oid(current_revision.oid)), term::format::dim(format!("R{}", current_version + 1)), term::format::secondary(term::format::oid(*head)), diff --git a/radicle-cli/src/commands/patch/show.rs b/radicle-cli/src/commands/patch/show.rs index e1fad6d1..76a6555b 100644 --- a/radicle-cli/src/commands/patch/show.rs +++ b/radicle-cli/src/commands/patch/show.rs @@ -29,11 +29,11 @@ pub fn run( ) -> anyhow::Result<()> { let patches = patch::Patches::open(profile.public_key, storage)?; let Some(patch) = patches.get(patch_id)? else { - anyhow::bail!("Patch `{}` not found", patch_id); + anyhow::bail!("Patch `{patch_id}` not found"); }; term::blank(); - term::print(format!("patch {}", patch_id)); + term::print(format!("patch {patch_id}")); term::blank(); term::patch::print_title_desc(patch.title(), patch.description().unwrap_or("")); diff --git a/radicle-cli/src/commands/review.rs b/radicle-cli/src/commands/review.rs index 8925ca55..baf19a4d 100644 --- a/radicle-cli/src/commands/review.rs +++ b/radicle-cli/src/commands/review.rs @@ -138,13 +138,13 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { let repository = profile.storage.repository(id)?; let _project = repository .identity_of(profile.id()) - .context(format!("couldn't load project {} from local state", id))?; + .context(format!("couldn't load project {id} from local state"))?; let mut patches = Patches::open(*profile.id(), &repository)?; let patch_id = options.id; let mut patch = patches .get_mut(&patch_id) - .context(format!("couldn't find patch {} locally", patch_id))?; + .context(format!("couldn't find patch {patch_id} locally"))?; let patch_id_pretty = term::format::tertiary(term::format::cob(&patch_id)); let revision_ix = options.revision.unwrap_or_else(|| patch.version()); let (revision_id, _) = patch @@ -162,7 +162,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { "{} {} {} by {}?", verdict_pretty, patch_id_pretty, - term::format::dim(format!("R{}", revision_ix)), + term::format::dim(format!("R{revision_ix}")), term::format::tertiary(patch.author().id()) )) { anyhow::bail!("Patch review aborted"); diff --git a/radicle-cli/src/git.rs b/radicle-cli/src/git.rs index 61c7c59a..1bfe1850 100644 --- a/radicle-cli/src/git.rs +++ b/radicle-cli/src/git.rs @@ -195,7 +195,7 @@ pub fn set_tracking(repo: &Repository, remote: &NodeId, branch: &str) -> anyhow: /// Get the name of the remote of the given branch, if any. pub fn branch_remote(repo: &Repository, branch: &str) -> anyhow::Result { let cfg = repo.config()?; - let remote = cfg.get_string(&format!("branch.{}.remote", branch))?; + let remote = cfg.get_string(&format!("branch.{branch}.remote"))?; Ok(remote) } diff --git a/radicle-cli/src/main.rs b/radicle-cli/src/main.rs index 41aebdfc..81f3b077 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); } @@ -64,15 +64,15 @@ fn parse_args() -> anyhow::Result { fn print_version() { if VERSION.contains("-dev") { - println!("{} {}+{}", NAME, VERSION, GIT_HEAD) + println!("{NAME} {VERSION}+{GIT_HEAD}") } else { - println!("{} {}", NAME, VERSION) + println!("{NAME} {VERSION}") } } fn print_help() -> anyhow::Result<()> { print_version(); - println!("{}", DESCRIPTION); + println!("{DESCRIPTION}"); println!(); rad_help::run(Default::default(), term::profile) @@ -285,7 +285,7 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option> args.to_vec(), ), _ => { - let exe = format!("{}-{}", NAME, exe); + let exe = format!("{NAME}-{exe}"); let status = process::Command::new(exe.clone()).args(args).status(); match status { diff --git a/radicle-cli/src/terminal.rs b/radicle-cli/src/terminal.rs index d15b48ba..f437c585 100644 --- a/radicle-cli/src/terminal.rs +++ b/radicle-cli/src/terminal.rs @@ -114,7 +114,7 @@ where match cmd.run(options, self::profile) { Ok(()) => process::exit(0), Err(err) => { - term::fail(&format!("{} failed", action), &err); + term::fail(&format!("{action} failed"), &err); process::exit(1); } } diff --git a/radicle-cli/src/terminal/args.rs b/radicle-cli/src/terminal/args.rs index 99ea922c..ece18463 100644 --- a/radicle-cli/src/terminal/args.rs +++ b/radicle-cli/src/terminal/args.rs @@ -56,8 +56,8 @@ where pub fn format(arg: lexopt::Arg) -> OsString { match arg { - lexopt::Arg::Long(flag) => format!("--{}", flag).into(), - lexopt::Arg::Short(flag) => format!("-{}", flag).into(), + lexopt::Arg::Long(flag) => format!("--{flag}").into(), + lexopt::Arg::Short(flag) => format!("-{flag}").into(), lexopt::Arg::Value(val) => val, } } diff --git a/radicle-cli/src/terminal/format.rs b/radicle-cli/src/terminal/format.rs index a74bedae..a5ec7fe7 100644 --- a/radicle-cli/src/terminal/format.rs +++ b/radicle-cli/src/terminal/format.rs @@ -14,7 +14,7 @@ pub fn node(node: &NodeId) -> String { let start = node.chars().take(7).collect::(); let end = node.chars().skip(node.len() - 7).collect::(); - format!("{}…{}", start, end) + format!("{start}…{end}") } /// Format a git Oid. @@ -83,7 +83,7 @@ impl<'a> fmt::Display for Identity<'a> { term::format::dim(username) ) } else { - write!(f, "{} {}", node_id, username) + write!(f, "{node_id} {username}") } } } @@ -117,22 +117,19 @@ pub fn highlight(input: D) -> String { } pub fn badge_primary(input: D) -> String { - style(format!(" {} ", input)) - .magenta() - .reverse() - .to_string() + style(format!(" {input} ")).magenta().reverse().to_string() } pub fn badge_positive(input: D) -> String { - style(format!(" {} ", input)).green().reverse().to_string() + style(format!(" {input} ")).green().reverse().to_string() } pub fn badge_negative(input: D) -> String { - style(format!(" {} ", input)).red().reverse().to_string() + style(format!(" {input} ")).red().reverse().to_string() } pub fn badge_secondary(input: D) -> String { - style(format!(" {} ", input)).blue().reverse().to_string() + style(format!(" {input} ")).blue().reverse().to_string() } pub fn bold(input: D) -> String { diff --git a/radicle-cli/src/terminal/io.rs b/radicle-cli/src/terminal/io.rs index e8e8cff6..56b046c3 100644 --- a/radicle-cli/src/terminal/io.rs +++ b/radicle-cli/src/terminal/io.rs @@ -45,15 +45,11 @@ pub use success; pub use tip; pub fn success_args(args: fmt::Arguments) { - println!("{} {}", style("ok").green().reverse(), args); + println!("{} {args}", style("ok").green().reverse()); } pub fn tip_args(args: fmt::Arguments) { - println!( - "{} {}", - style("=>").blue(), - style(format!("{}", args)).dim() - ); + println!("{} {}", style("=>").blue(), style(format!("{args}")).dim()); } pub fn width() -> Option { @@ -77,34 +73,34 @@ pub fn blank() { } pub fn print(msg: impl fmt::Display) { - println!("{}", msg); + println!("{msg}"); } pub fn prefixed(prefix: &str, text: &str) -> String { text.split('\n') - .map(|line| format!("{}{}\n", prefix, line)) + .map(|line| format!("{prefix}{line}\n")) .collect() } pub fn help(name: &str, version: &str, description: &str, usage: &str) { - println!("rad-{} {}\n{}\n{}", name, version, description, usage); + println!("rad-{name} {version}\n{description}\n{usage}"); } pub fn usage(name: &str, usage: &str) { eprintln!( "{} {}\n{}", style("==").red(), - style(format!("Error: rad-{}: invalid usage", name)).red(), + style(format!("Error: rad-{name}: invalid usage")).red(), style(prefixed(TAB, usage)).red().dim() ); } pub fn eprintln(prefix: impl fmt::Display, msg: impl fmt::Display) { - eprintln!("{} {}", prefix, msg); + eprintln!("{prefix} {msg}"); } pub fn indented(msg: impl fmt::Display) { - println!("{}{}", TAB, msg); + println!("{TAB}{msg}"); } pub fn subcommand(msg: impl fmt::Display) { @@ -233,7 +229,7 @@ pub struct Optional { impl fmt::Display for Optional { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(val) = &self.option { - write!(f, "{}", val) + write!(f, "{val}") } else { write!(f, "") } @@ -392,5 +388,5 @@ pub fn markdown(content: &str) { } fn _info(args: std::fmt::Arguments) { - println!("{}", args); + println!("{args}"); } diff --git a/radicle-cli/src/terminal/patch.rs b/radicle-cli/src/terminal/patch.rs index d74c165f..b7c83d4a 100644 --- a/radicle-cli/src/terminal/patch.rs +++ b/radicle-cli/src/terminal/patch.rs @@ -87,7 +87,7 @@ pub fn print_commits_ahead_behind( /// Print title and description in a text box. pub fn print_title_desc(title: &str, description: &str) { - let title_pretty = &term::format::dim(format!("╭─ {} ───────", title)); + let title_pretty = &term::format::dim(format!("╭─ {title} ───────")); term::print(title_pretty); term::blank(); diff --git a/radicle-cli/src/terminal/table.rs b/radicle-cli/src/terminal/table.rs index c3cd17d1..887155b2 100644 --- a/radicle-cli/src/terminal/table.rs +++ b/radicle-cli/src/terminal/table.rs @@ -66,7 +66,7 @@ impl Table { for (i, cell) in row.iter().enumerate() { if i == cells - 1 || self.opts.overflow { - write!(output, "{}", cell).ok(); + write!(output, "{cell}").ok(); } else { write!( output, diff --git a/radicle-cob/src/test/identity/person.rs b/radicle-cob/src/test/identity/person.rs index 36ac6c33..45ab286e 100644 --- a/radicle-cob/src/test/identity/person.rs +++ b/radicle-cob/src/test/identity/person.rs @@ -25,7 +25,7 @@ impl Person { key: crypto::PublicKey, ) -> Result { let repo = repo.as_raw(); - let refname = format!("refs/rad/identities/{}", name); + let refname = format!("refs/rad/identities/{name}"); let payload = Payload { name: Name(name.to_owned()), key, diff --git a/radicle-cob/src/test/identity/project.rs b/radicle-cob/src/test/identity/project.rs index 9a8448cc..705f6ffd 100644 --- a/radicle-cob/src/test/identity/project.rs +++ b/radicle-cob/src/test/identity/project.rs @@ -42,7 +42,7 @@ impl Project { delegate: crypto::PublicKey, ) -> Result { let repo = repo.as_raw(); - let refname = format!("refs/rad/identities/{}", name); + let refname = format!("refs/rad/identities/{name}"); let payload = Payload { name: Name(name.to_owned()), delegates: Some(delegate).into_iter().collect(), diff --git a/radicle-cob/src/test/storage.rs b/radicle-cob/src/test/storage.rs index 69faef97..896e7851 100644 --- a/radicle-cob/src/test/storage.rs +++ b/radicle-cob/src/test/storage.rs @@ -105,7 +105,7 @@ impl object::Storage for Storage { typename: &crate::TypeName, object_id: &ObjectId, ) -> Result { - let glob = format!("refs/rad/*/cobs/{}/{}", typename, object_id); + let glob = format!("refs/rad/*/cobs/{typename}/{object_id}"); let remotes = self .raw .references_glob(&glob)? @@ -125,7 +125,7 @@ impl object::Storage for Storage { for r in self.raw.references_glob("refs/rad/*")? { let r = r?; let name = r.name().unwrap(); - println!("NAME: {}", name); + println!("NAME: {name}"); let oid = r .target() .map(ObjectId::from) diff --git a/radicle-crypto/src/hash.rs b/radicle-crypto/src/hash.rs index 8715c4d4..5c676f27 100644 --- a/radicle-crypto/src/hash.rs +++ b/radicle-crypto/src/hash.rs @@ -31,14 +31,14 @@ impl AsRef<[u8; 32]> for Digest { impl fmt::Debug for Digest { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "Hash({})", self) + write!(f, "Hash({self})") } } impl fmt::Display for Digest { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { for byte in &self.0 { - write!(f, "{:02x}", byte)?; + write!(f, "{byte:02x}")?; } Ok(()) } diff --git a/radicle-crypto/src/lib.rs b/radicle-crypto/src/lib.rs index c9b7f432..fdb1199b 100644 --- a/radicle-crypto/src/lib.rs +++ b/radicle-crypto/src/lib.rs @@ -89,7 +89,7 @@ impl fmt::Display for Signature { impl fmt::Debug for Signature { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "Signature({})", self) + write!(f, "Signature({self})") } } @@ -366,7 +366,7 @@ impl From for String { impl fmt::Debug for PublicKey { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "PublicKey({})", self) + write!(f, "PublicKey({self})") } } diff --git a/radicle-crypto/src/ssh.rs b/radicle-crypto/src/ssh.rs index 4de281c5..e77f9234 100644 --- a/radicle-crypto/src/ssh.rs +++ b/radicle-crypto/src/ssh.rs @@ -44,7 +44,7 @@ pub mod fmt { let sha = sha2::Sha256::digest(&buf).to_vec(); let encoded = base64::encode_config(sha, base64::STANDARD_NO_PAD); - format!("SHA256:{}", encoded) + format!("SHA256:{encoded}") } #[cfg(test)] diff --git a/radicle-dag/src/lib.rs b/radicle-dag/src/lib.rs index 033318ff..ce40811d 100644 --- a/radicle-dag/src/lib.rs +++ b/radicle-dag/src/lib.rs @@ -185,7 +185,7 @@ impl Index<&K> for Dag { fn index(&self, key: &K) -> &Self::Output { self.get(key) - .unwrap_or_else(|| panic!("Dag::index: node {:?} not found in graph", key)) + .unwrap_or_else(|| panic!("Dag::index: node {key:?} not found in graph")) } } @@ -298,7 +298,7 @@ mod tests { let expected: &[&[i32]] = &[&[0, 1, 2, 3], &[0, 2, 1, 3]]; let actual = dag.sorted(fastrand::Rng::new()); - assert!(expected.contains(&actual.as_slice()), "{:?}", actual); + assert!(expected.contains(&actual.as_slice()), "{actual:?}"); } #[test] diff --git a/radicle-httpd/src/api/axum_extra.rs b/radicle-httpd/src/api/axum_extra.rs index 0e1b1386..79a23e13 100644 --- a/radicle-httpd/src/api/axum_extra.rs +++ b/radicle-httpd/src/api/axum_extra.rs @@ -39,7 +39,7 @@ where } _ => Json(Error { success: false, - error: format!("{}", rejection), + error: format!("{rejection}"), }), }; @@ -72,7 +72,7 @@ where }), _ => Json(Error { success: false, - error: format!("{}", rejection), + error: format!("{rejection}"), }), }; diff --git a/radicle-httpd/src/lib.rs b/radicle-httpd/src/lib.rs index fe5bd696..4674b011 100644 --- a/radicle-httpd/src/lib.rs +++ b/radicle-httpd/src/lib.rs @@ -254,7 +254,7 @@ async fn git_http_backend( Err(Error::Backend) } Err(err) => { - panic!("failed to wait for git-http-backend: {}", err); + panic!("failed to wait for git-http-backend: {err}"); } } } diff --git a/radicle-node/src/control.rs b/radicle-node/src/control.rs index c3934e50..93e23ac5 100644 --- a/radicle-node/src/control.rs +++ b/radicle-node/src/control.rs @@ -42,7 +42,7 @@ pub fn listen>( handle.shutdown().ok(); break; } - writeln!(stream, "error: {}", e).ok(); + writeln!(stream, "error: {e}").ok(); stream.flush().ok(); stream.shutdown(net::Shutdown::Both).ok(); @@ -244,30 +244,29 @@ fn fetch>( { match result.result { Ok(updated) => { - writeln!(writer, "ok: {} fetched from {}", &id, result.remote)?; - + writeln!(writer, "ok: {id} fetched from {}", result.remote)?; for update in updated { - writeln!(writer, "{}", update)?; + writeln!(writer, "{update}")?; } } Err(err) => { writeln!( writer, - "error: {} failed to fetch from {}: {}", - &id, result.remote, err + "error: {id} failed to fetch from {}: {err}", + result.remote )?; } } } } Ok(FetchLookup::NotFound) => { - writeln!(writer, "error: {} was not found", &id)?; + writeln!(writer, "error: {id} was not found")?; } Ok(FetchLookup::NotTracking) => { - writeln!(writer, "error: {} is not tracked", &id)?; + writeln!(writer, "error: {id} is not tracked")?; } Ok(FetchLookup::Error(err)) => { - writeln!(writer, "error: {}", err)?; + writeln!(writer, "error: {err}")?; } } Ok(()) diff --git a/radicle-node/src/logger.rs b/radicle-node/src/logger.rs index 57ed1d9c..e7114da0 100644 --- a/radicle-node/src/logger.rs +++ b/radicle-node/src/logger.rs @@ -45,7 +45,7 @@ impl Log for Logger { Level::Debug => message.dimmed(), Level::Trace => message.white().dimmed(), }; - writeln!(stream, "{}", message).expect("write shouldn't fail"); + writeln!(stream, "{message}").expect("write shouldn't fail"); } } } diff --git a/radicle-node/src/service.rs b/radicle-node/src/service.rs index 101f27e4..cd9a1154 100644 --- a/radicle-node/src/service.rs +++ b/radicle-node/src/service.rs @@ -122,13 +122,13 @@ pub enum Command { impl fmt::Debug for Command { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::AnnounceRefs(id) => write!(f, "AnnounceRefs({})", id), - Self::Connect(id, addr) => write!(f, "Connect({}, {})", id, addr), - Self::Fetch(id, _) => write!(f, "Fetch({})", id), - Self::TrackRepo(id, _) => write!(f, "TrackRepo({})", id), - Self::UntrackRepo(id, _) => write!(f, "UntrackRepo({})", id), - Self::TrackNode(id, _, _) => write!(f, "TrackNode({})", id), - Self::UntrackNode(id, _) => write!(f, "UntrackNode({})", id), + Self::AnnounceRefs(id) => write!(f, "AnnounceRefs({id})"), + Self::Connect(id, addr) => write!(f, "Connect({id}, {addr})"), + Self::Fetch(id, _) => write!(f, "Fetch({id})"), + Self::TrackRepo(id, _) => write!(f, "TrackRepo({id})"), + Self::UntrackRepo(id, _) => write!(f, "UntrackRepo({id})"), + Self::TrackNode(id, _, _) => write!(f, "TrackNode({id})"), + Self::UntrackNode(id, _) => write!(f, "UntrackNode({id})"), Self::QueryState { .. } => write!(f, "QueryState(..)"), } } @@ -1223,10 +1223,10 @@ impl DisconnectReason { impl fmt::Display for DisconnectReason { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Dial(err) => write!(f, "{}", err), - Self::Connection(err) => write!(f, "{}", err), - Self::Session(err) => write!(f, "error: {}", err), - Self::Fetch(err) => write!(f, "fetch: {}", err), + Self::Dial(err) => write!(f, "{err}"), + Self::Connection(err) => write!(f, "{err}"), + Self::Session(err) => write!(f, "error: {err}"), + Self::Fetch(err) => write!(f, "fetch: {err}"), } } } diff --git a/radicle-node/src/service/message.rs b/radicle-node/src/service/message.rs index 17b557e0..0f7c6870 100644 --- a/radicle-node/src/service/message.rs +++ b/radicle-node/src/service/message.rs @@ -387,13 +387,13 @@ impl fmt::Debug for Message { match self { Self::Initialize { .. } => write!(f, "Initialize(..)"), Self::Subscribe(Subscribe { since, until, .. }) => { - write!(f, "Subscribe({}..{})", since, until) + write!(f, "Subscribe({since}..{until})") } Self::Announcement(Announcement { node, message, .. }) => { - write!(f, "Announcement({}, {:?})", node, message) + write!(f, "Announcement({node}, {message:?})") } - Self::Ping(Ping { ponglen, zeroes }) => write!(f, "Ping({ponglen}, {:?})", zeroes), - Self::Pong { zeroes } => write!(f, "Pong({:?})", zeroes), + Self::Ping(Ping { ponglen, zeroes }) => write!(f, "Ping({ponglen}, {zeroes:?})"), + Self::Pong { zeroes } => write!(f, "Pong({zeroes:?})"), Self::Fetch { rid } => write!(f, "Fetch({rid})"), Self::FetchOk { rid } => write!(f, "FetchOk({rid})"), } diff --git a/radicle-node/src/test/logger.rs b/radicle-node/src/test/logger.rs index 3b65cb2f..5777e004 100644 --- a/radicle-node/src/test/logger.rs +++ b/radicle-node/src/test/logger.rs @@ -22,9 +22,9 @@ impl Log for Logger { target => { if self.enabled(record.metadata()) { let current = std::thread::current(); - let msg = format!("{:>12} {}", format!("{}:", target), record.args()); + let msg = format!("{:>12} {}", format!("{target}:"), record.args()); let s = if let Some(name) = current.name() { - format!("{:<16} {msg}", name) + format!("{name:<16} {msg}") } else { msg }; diff --git a/radicle-node/src/test/simulator.rs b/radicle-node/src/test/simulator.rs index f2a1e91f..eb4dbb3b 100644 --- a/radicle-node/src/test/simulator.rs +++ b/radicle-node/src/test/simulator.rs @@ -423,10 +423,7 @@ impl Simulation { self.schedule(&node, o); } } else { - panic!( - "Node {} not found when attempting to schedule {:?}", - node, input - ); + panic!("Node {node} not found when attempting to schedule {input:?}",); } } !self.is_done() diff --git a/radicle-node/src/tests/e2e.rs b/radicle-node/src/tests/e2e.rs index cd1d7356..cf9b246e 100644 --- a/radicle-node/src/tests/e2e.rs +++ b/radicle-node/src/tests/e2e.rs @@ -350,7 +350,7 @@ fn test_replication() { let (seeds, results) = match alice.handle.fetch(acme).unwrap() { FetchLookup::Found { seeds, results } => (seeds, results), - other => panic!("Fetch lookup failed, got {:?}", other), + other => panic!("Fetch lookup failed, got {other:?}"), }; assert_eq!(seeds, nonempty::NonEmpty::new(bob.id)); @@ -409,7 +409,7 @@ fn test_clone() { match lookup { // Drain the channel. FetchLookup::Found { seeds, results } => for _ in results.iter().take(seeds.len()) {}, - other => panic!("Unexpected fetch lookup: {:?}", other), + other => panic!("Unexpected fetch lookup: {other:?}"), } rad::fork(acme, &alice.signer, &alice.storage).unwrap(); @@ -458,12 +458,12 @@ fn test_fetch_up_to_date() { match alice.handle.fetch(acme).unwrap() { FetchLookup::Found { seeds, results } => for _ in results.iter().take(seeds.len()) {}, - other => panic!("Unexpected fetch lookup: {:?}", other), + other => panic!("Unexpected fetch lookup: {other:?}"), } // Fetch again! This time, everything's up to date. match alice.handle.fetch(acme).unwrap() { FetchLookup::Found { seeds, results } => for _ in results.iter().take(seeds.len()) {}, - other => panic!("Unexpected fetch lookup: {:?}", other), + other => panic!("Unexpected fetch lookup: {other:?}"), } } diff --git a/radicle-node/src/wire/protocol.rs b/radicle-node/src/wire/protocol.rs index ace54ffe..ab894a0a 100644 --- a/radicle-node/src/wire/protocol.rs +++ b/radicle-node/src/wire/protocol.rs @@ -86,7 +86,7 @@ enum Peer { impl std::fmt::Debug for Peer { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Self::Connecting { link } => write!(f, "Connecting({:?})", link), + Self::Connecting { link } => write!(f, "Connecting({link:?})"), Self::Connected { link, id } => write!(f, "Connected({link:?}, {id})"), Self::Disconnected { reason, id } => write!(f, "Disconnected({reason}, {id:?})"), Self::Upgrading { fetch, link, id } => write!( @@ -121,7 +121,7 @@ impl Peer { if let Self::Connecting { link } = self { *self = Self::Connected { link: *link, id }; } else { - panic!("Peer::connected: session for {} is already established", id); + panic!("Peer::connected: session for {id} is already established"); } } @@ -135,7 +135,7 @@ impl Peer { } else if let Self::Connecting { .. } = self { *self = Self::Disconnected { id: None, reason }; } else { - panic!("Peer::disconnected: session is not connected ({:?})", self); + panic!("Peer::disconnected: session is not connected ({self:?})"); } } diff --git a/radicle-remote-helper/src/git-remote-rad.rs b/radicle-remote-helper/src/git-remote-rad.rs index f08f1e52..d8c99828 100644 --- a/radicle-remote-helper/src/git-remote-rad.rs +++ b/radicle-remote-helper/src/git-remote-rad.rs @@ -2,13 +2,13 @@ fn main() { let profile = match radicle::Profile::load() { Ok(profile) => profile, Err(err) => { - eprintln!("fatal: couldn't load profile: {}", err); + eprintln!("fatal: couldn't load profile: {err}"); std::process::exit(1); } }; if let Err(err) = radicle_remote_helper::run(profile) { - eprintln!("fatal: {}", err); + eprintln!("fatal: {err}"); std::process::exit(1); } } diff --git a/radicle-tools/src/rad-init.rs b/radicle-tools/src/rad-init.rs index ce278cdc..7722f720 100644 --- a/radicle-tools/src/rad-init.rs +++ b/radicle-tools/src/rad-init.rs @@ -17,7 +17,7 @@ fn main() -> anyhow::Result<()> { &profile.storage, )?; - println!("ok: {}", id); + println!("ok: {id}"); Ok(()) } diff --git a/radicle-tools/src/rad-push.rs b/radicle-tools/src/rad-push.rs index 461b0229..84b03732 100644 --- a/radicle-tools/src/rad-push.rs +++ b/radicle-tools/src/rad-push.rs @@ -9,7 +9,7 @@ fn main() -> anyhow::Result<()> { let (_, id) = radicle::rad::remote(&repo)?; let output = radicle::git::run::<_, _, &str, &str>(&cwd, ["push", "rad"], None)?; - println!("{}", output); + println!("{output}"); let signer = profile.signer()?; let project = profile.storage.repository(id)?; @@ -18,7 +18,7 @@ fn main() -> anyhow::Result<()> { radicle::Node::new(profile.socket()).announce_refs(id)?; - println!("head: {}", head); + println!("head: {head}"); println!("ok: {}", sigrefs.signature); Ok(()) diff --git a/radicle/src/git.rs b/radicle/src/git.rs index 8e17723e..01ce63fc 100644 --- a/radicle/src/git.rs +++ b/radicle/src/git.rs @@ -428,8 +428,8 @@ pub fn set_upstream( merge: &str, ) -> Result<(), git2::Error> { let mut config = repo.config()?; - let branch_remote = format!("branch.{}.remote", branch); - let branch_merge = format!("branch.{}.merge", branch); + let branch_remote = format!("branch.{branch}.remote"); + let branch_merge = format!("branch.{branch}.merge"); config.remove_multivar(&branch_remote, ".*").or_else(|e| { if ext::is_not_found_err(&e) { diff --git a/radicle/src/identity.rs b/radicle/src/identity.rs index 03aef869..f560855c 100644 --- a/radicle/src/identity.rs +++ b/radicle/src/identity.rs @@ -164,13 +164,13 @@ mod test { #[quickcheck] fn prop_json_eq_str(pk: PublicKey, proj: Id, did: Did) { let json = serde_json::to_string(&pk).unwrap(); - assert_eq!(format!("\"{}\"", pk), json); + assert_eq!(format!("\"{pk}\""), json); let json = serde_json::to_string(&proj).unwrap(); assert_eq!(format!("\"{}\"", proj.urn()), json); let json = serde_json::to_string(&did).unwrap(); - assert_eq!(format!("\"{}\"", did), json); + assert_eq!(format!("\"{did}\""), json); } #[test] diff --git a/radicle/src/identity/doc/id.rs b/radicle/src/identity/doc/id.rs index ec95cc20..bfe0c7c2 100644 --- a/radicle/src/identity/doc/id.rs +++ b/radicle/src/identity/doc/id.rs @@ -33,7 +33,7 @@ impl fmt::Display for Id { impl fmt::Debug for Id { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "Id({})", self) + write!(f, "Id({self})") } } diff --git a/radicle/src/storage.rs b/radicle/src/storage.rs index b1e877e7..65faf962 100644 --- a/radicle/src/storage.rs +++ b/radicle/src/storage.rs @@ -121,16 +121,16 @@ impl fmt::Display for RefUpdate { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::Updated { name, old, new } => { - write!(f, "~ {:.7}..{:.7} {}", old, new, name) + write!(f, "~ {old:.7}..{new:.7} {name}") } Self::Created { name, oid } => { - write!(f, "* 0000000..{:.7} {}", oid, name) + write!(f, "* 0000000..{oid:.7} {name}") } Self::Deleted { name, oid } => { - write!(f, "- {:.7}..0000000 {}", oid, name) + write!(f, "- {oid:.7}..0000000 {name}") } Self::Skipped { name, oid } => { - write!(f, "= {:.7}..{:.7} {}", oid, oid, name) + write!(f, "= {oid:.7}..{oid:.7} {name}") } } } diff --git a/radicle/src/storage/git.rs b/radicle/src/storage/git.rs index 186e9f21..c5a32f2b 100644 --- a/radicle/src/storage/git.rs +++ b/radicle/src/storage/git.rs @@ -168,7 +168,7 @@ impl Storage { let name = r.name().ok_or(Error::InvalidRef)?; let oid = r.target().ok_or(Error::InvalidRef)?; - println!("{} {} {}", proj.urn(), oid, name); + println!("{} {oid} {name}", proj.urn()); } } Ok(()) @@ -250,7 +250,7 @@ impl Repository { let name = r.name().ok_or(Error::InvalidRef)?; let oid = r.target().ok_or(Error::InvalidRef)?; - println!("{} {}", oid, name); + println!("{oid} {name}"); } Ok(()) } diff --git a/radicle/src/storage/refs.rs b/radicle/src/storage/refs.rs index ca59a7d5..8af765d1 100644 --- a/radicle/src/storage/refs.rs +++ b/radicle/src/storage/refs.rs @@ -313,7 +313,7 @@ impl SignedRefs { Some(&sigref), &author, &author, - &format!("Update signature for {}\n", remote), + &format!("Update signature for {remote}\n"), &tree, &parent.iter().collect::>(), ); diff --git a/rust-toolchain b/rust-toolchain index 9cf4011b..9ebd7af3 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.66 +1.67