Skip to content

Commit

Permalink
style: Inline fmt args
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Sep 27, 2024
1 parent 34ab3f8 commit ad5602f
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 24 deletions.
6 changes: 3 additions & 3 deletions examples/example_fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use std::process;

fn run() -> Result<(), Box<dyn Error>> {
if let Ok(text) = env::var("stdout") {
println!("{}", text);
println!("{text}");
}
if let Ok(text) = env::var("stderr") {
eprintln!("{}", text);
eprintln!("{text}");
}

let code = env::var("exit")
Expand All @@ -25,7 +25,7 @@ fn main() {
let code = match run() {
Ok(_) => 0,
Err(ref e) => {
write!(&mut io::stderr(), "{}", e).expect("writing to stderr won't fail");
write!(&mut io::stderr(), "{e}").expect("writing to stderr won't fail");
1
}
};
Expand Down
6 changes: 3 additions & 3 deletions src/bin/bin_fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use std::process;

fn run() -> Result<(), Box<dyn Error>> {
if let Ok(text) = env::var("stdout") {
println!("{}", text);
println!("{text}");
}
if let Ok(text) = env::var("stderr") {
eprintln!("{}", text);
eprintln!("{text}");
}

let code = env::var("exit")
Expand All @@ -25,7 +25,7 @@ fn main() {
let code = match run() {
Ok(_) => 0,
Err(ref e) => {
write!(&mut io::stderr(), "{}", e).expect("writing to stderr won't fail");
write!(&mut io::stderr(), "{e}").expect("writing to stderr won't fail");
1
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ impl fmt::Display for CargoError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "Cargo command failed: {}", self.kind)?;
if let Some(ref context) = self.context {
writeln!(f, "{}", context)?;
writeln!(f, "{context}")?;
}
if let Some(ref cause) = self.cause {
writeln!(f, "Cause: {}", cause)?;
writeln!(f, "Cause: {cause}")?;
}
Ok(())
}
Expand Down
10 changes: 5 additions & 5 deletions src/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,11 @@ pub(crate) fn log_message(msg: &Message<'_>) {
.map(|s| s.as_ref())
.unwrap_or_else(|| comp.message.message.as_ref());
match comp.message.level {
diagnostic::DiagnosticLevel::Ice => eprintln!("{}", content),
diagnostic::DiagnosticLevel::Error => eprintln!("{}", content),
diagnostic::DiagnosticLevel::Warning => eprintln!("{}", content),
diagnostic::DiagnosticLevel::Note => eprintln!("{}", content),
diagnostic::DiagnosticLevel::Help => eprintln!("{}", content),
diagnostic::DiagnosticLevel::Ice => eprintln!("{content}"),
diagnostic::DiagnosticLevel::Error => eprintln!("{content}"),
diagnostic::DiagnosticLevel::Warning => eprintln!("{content}"),
diagnostic::DiagnosticLevel::Note => eprintln!("{content}"),
diagnostic::DiagnosticLevel::Help => eprintln!("{content}"),
#[cfg(not(feature = "strict_unstable"))]
_ => eprintln!("Unknown message: {:#?}", msg),
}
Expand Down
8 changes: 2 additions & 6 deletions src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,8 @@ fn extract_binary_path(
if bins.is_empty() {
return Err(CargoError::new(ErrorKind::CommandFailed).set_context("No binaries in crate"));
} else if bins.len() != 1 {
return Err(
CargoError::new(ErrorKind::CommandFailed).set_context(std::format!(
"Ambiguous which binary is intended: {:?}",
bins
)),
);
return Err(CargoError::new(ErrorKind::CommandFailed)
.set_context(std::format!("Ambiguous which binary is intended: {bins:?}")));
}
Ok(bins.into_iter().next().expect("already validated"))
}
8 changes: 4 additions & 4 deletions tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fn test_fixture(name: &str) {
let temp = tempfile::TempDir::new().unwrap();

let msgs = escargot::CargoBuild::new()
.manifest_path(format!("tests/testsuite/fixtures/{}/Cargo.toml", name))
.manifest_path(format!("tests/testsuite/fixtures/{name}/Cargo.toml"))
.current_release()
.current_target()
.target_dir(temp.path())
Expand All @@ -12,8 +12,8 @@ fn test_fixture(name: &str) {
let raw_msg = msg.unwrap();
let msg = raw_msg.decode();
match msg {
Ok(msg) => println!("{:#?}", msg),
Err(err) => panic!("{}\nmsg=`{:#?}`", err, raw_msg),
Ok(msg) => println!("{msg:#?}"),
Err(err) => panic!("{err}\nmsg=`{raw_msg:#?}`"),
}
}
}
Expand Down Expand Up @@ -62,7 +62,7 @@ fn test_error() {
for msg in &msgs[0..error_idx] {
let msg = msg.as_ref().unwrap();
let msg = msg.decode().unwrap();
println!("{:#?}", msg);
println!("{msg:#?}");
}
assert!(msgs[error_idx].is_err());
println!("```{}```", msgs[error_idx].as_ref().err().unwrap());
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fn test_fixture(name: &str) {
let temp = tempfile::TempDir::new().unwrap();

let cmd = escargot::CargoBuild::new()
.manifest_path(format!("tests/testsuite/fixtures/{}/Cargo.toml", name))
.manifest_path(format!("tests/testsuite/fixtures/{name}/Cargo.toml"))
.current_release()
.current_target()
.target_dir(temp.path())
Expand Down

0 comments on commit ad5602f

Please sign in to comment.