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 <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
Fintan Halpenny 2023-02-03 13:43:30 +00:00 committed by Alexis Sellier
parent c1ba45fcd8
commit 3f48c2c516
No known key found for this signature in database
46 changed files with 121 additions and 132 deletions

View File

@ -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

View File

@ -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/<owner>/<repo>/archive/<rev>.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/<owner>/<repo>/archive/<rev>.tar.gz"
}
}

View File

@ -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");
}

View File

@ -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);
}

View File

@ -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])?;
}
}

View File

@ -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() {

View File

@ -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())?;

View File

@ -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<Vec<git::raw::Commit<'a>>> {
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?)?;

View File

@ -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<G: Signer>(
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)),

View File

@ -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(""));

View File

@ -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");

View File

@ -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<String> {
let cfg = repo.config()?;
let remote = cfg.get_string(&format!("branch.{}.remote", branch))?;
let remote = cfg.get_string(&format!("branch.{branch}.remote"))?;
Ok(remote)
}

View File

@ -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<Command> {
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<anyhow::Error>>
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 {

View File

@ -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);
}
}

View File

@ -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,
}
}

View File

@ -14,7 +14,7 @@ pub fn node(node: &NodeId) -> String {
let start = node.chars().take(7).collect::<String>();
let end = node.chars().skip(node.len() - 7).collect::<String>();
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<D: std::fmt::Display>(input: D) -> String {
}
pub fn badge_primary<D: std::fmt::Display>(input: D) -> String {
style(format!(" {} ", input))
.magenta()
.reverse()
.to_string()
style(format!(" {input} ")).magenta().reverse().to_string()
}
pub fn badge_positive<D: std::fmt::Display>(input: D) -> String {
style(format!(" {} ", input)).green().reverse().to_string()
style(format!(" {input} ")).green().reverse().to_string()
}
pub fn badge_negative<D: std::fmt::Display>(input: D) -> String {
style(format!(" {} ", input)).red().reverse().to_string()
style(format!(" {input} ")).red().reverse().to_string()
}
pub fn badge_secondary<D: std::fmt::Display>(input: D) -> String {
style(format!(" {} ", input)).blue().reverse().to_string()
style(format!(" {input} ")).blue().reverse().to_string()
}
pub fn bold<D: std::fmt::Display>(input: D) -> String {

View File

@ -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<usize> {
@ -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<T> {
impl<T: fmt::Display> fmt::Display for Optional<T> {
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}");
}

View File

@ -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();

View File

@ -66,7 +66,7 @@ impl<const W: usize> Table<W> {
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,

View File

@ -25,7 +25,7 @@ impl Person {
key: crypto::PublicKey,
) -> Result<Self, storage::error::Identity> {
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,

View File

@ -42,7 +42,7 @@ impl Project {
delegate: crypto::PublicKey,
) -> Result<Self, storage::error::Identity> {
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(),

View File

@ -105,7 +105,7 @@ impl object::Storage for Storage {
typename: &crate::TypeName,
object_id: &ObjectId,
) -> Result<object::Objects, Self::ObjectsError> {
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)

View File

@ -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(())
}

View File

@ -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<PublicKey> for String {
impl fmt::Debug for PublicKey {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "PublicKey({})", self)
write!(f, "PublicKey({self})")
}
}

View File

@ -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)]

View File

@ -185,7 +185,7 @@ impl<K: Eq + Copy + Hash + fmt::Debug, V> Index<&K> for Dag<K, V> {
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]

View File

@ -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}"),
}),
};

View File

@ -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}");
}
}
}

View File

@ -42,7 +42,7 @@ pub fn listen<H: Handle<Error = runtime::HandleError>>(
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<W: Write, H: Handle<Error = runtime::HandleError>>(
{
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(())

View File

@ -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");
}
}
}

View File

@ -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}"),
}
}
}

View File

@ -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})"),
}

View File

@ -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
};

View File

@ -423,10 +423,7 @@ impl<S: WriteStorage + 'static, G: Signer> Simulation<S, G> {
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()

View File

@ -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:?}"),
}
}

View File

@ -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:?})");
}
}

View File

@ -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);
}
}

View File

@ -17,7 +17,7 @@ fn main() -> anyhow::Result<()> {
&profile.storage,
)?;
println!("ok: {}", id);
println!("ok: {id}");
Ok(())
}

View File

@ -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(())

View File

@ -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) {

View File

@ -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]

View File

@ -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})")
}
}

View File

@ -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}")
}
}
}

View File

@ -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(())
}

View File

@ -313,7 +313,7 @@ impl SignedRefs<Verified> {
Some(&sigref),
&author,
&author,
&format!("Update signature for {}\n", remote),
&format!("Update signature for {remote}\n"),
&tree,
&parent.iter().collect::<Vec<&git2::Commit>>(),
);

View File

@ -1 +1 @@
1.66
1.67