Skip to content

Commit

Permalink
fix: inline format arguments (clippy)
Browse files Browse the repository at this point in the history
  • Loading branch information
huitseeker committed Sep 9, 2023
1 parent c900176 commit a259db1
Show file tree
Hide file tree
Showing 33 changed files with 119 additions and 136 deletions.
2 changes: 1 addition & 1 deletion benches/sha256_ivc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn sha256_ivc<F: LurkField>(
.map(|i| format!("(sha256 . {i})"))
.collect::<Vec<String>>()
.join(" ");
let input = format!("'({})", input);
let input = format!("'({input})");
let program = format!(
r#"
(letrec ((encode-1 (lambda (term)
Expand Down
8 changes: 4 additions & 4 deletions examples/circom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fn main() {
)],
);

let coproc_expr = format!("{}", sym_str);
let coproc_expr = format!("{sym_str}");

let expr = format!("({coproc_expr})");
let ptr = store.read(&expr).unwrap();
Expand All @@ -129,7 +129,7 @@ fn main() {
.unwrap();
let pp_end = pp_start.elapsed();

println!("Public parameters took {:?}", pp_end);
println!("Public parameters took {pp_end:?}");

println!("Beginning proof step...");

Expand All @@ -139,15 +139,15 @@ fn main() {
.unwrap();
let proof_end = proof_start.elapsed();

println!("Proofs took {:?}", proof_end);
println!("Proofs took {proof_end:?}");

println!("Verifying proof...");

let verify_start = Instant::now();
let res = proof.verify(&pp, num_steps, &z0, &zi).unwrap();
let verify_end = verify_start.elapsed();

println!("Verify took {:?}", verify_end);
println!("Verify took {verify_end:?}");

if res {
println!(
Expand Down
6 changes: 3 additions & 3 deletions examples/sha256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ fn main() {
.unwrap();
let pp_end = pp_start.elapsed();

println!("Public parameters took {:?}", pp_end);
println!("Public parameters took {pp_end:?}");

if setup_only {
return;
Expand All @@ -222,15 +222,15 @@ fn main() {
});
let proof_end = proof_start.elapsed();

println!("Proofs took {:?}", proof_end);
println!("Proofs took {proof_end:?}");

println!("Verifying proof...");

let verify_start = Instant::now();
let res = proof.verify(&pp, num_steps, &z0, &zi).unwrap();
let verify_end = verify_start.elapsed();

println!("Verify took {:?}", verify_end);
println!("Verify took {verify_end:?}");

if res {
println!(
Expand Down
2 changes: 1 addition & 1 deletion examples/sha256_ivc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn sha256_ivc<F: LurkField>(store: &mut Store<F>, n: usize, input: Vec<usize>) -
.map(|i| i.to_string())
.collect::<Vec<String>>()
.join(" ");
let input = format!("'({})", input);
let input = format!("'({input})");
let program = format!(
r#"
(letrec ((encode-1 (lambda (term)
Expand Down
4 changes: 2 additions & 2 deletions fcomm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ mod base64 {

pub type NovaProofCache = FileMap<String, Proof<'static, S1>>;
pub fn nova_proof_cache(reduction_count: usize) -> NovaProofCache {
FileMap::<String, Proof<'_, S1>>::new(format!("nova_proofs.{}", reduction_count)).unwrap()
FileMap::<String, Proof<'_, S1>>::new(format!("nova_proofs.{reduction_count}")).unwrap()
}

pub type CommittedExpressionMap = FileMap<Commitment<S1>, CommittedExpression<S1>>;
Expand Down Expand Up @@ -1261,7 +1261,7 @@ mod test {
Some(c) => commitment = c,
_ => panic!("new commitment missing"),
}
println!("Commitment: {:?}", commitment);
println!("Commitment: {commitment:?}");
}
}

Expand Down
2 changes: 1 addition & 1 deletion fcomm/tests/makefile_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn test_make_fcomm_examples() {

let make_output = Command::new("make")
.current_dir(examples_dir)
.arg(format!("-j{}", cpus))
.arg(format!("-j{cpus}"))
.output()
.expect("Failed to run the make command, is make installed?");

Expand Down
17 changes: 7 additions & 10 deletions lurk-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,10 @@ pub fn serde_test(args: TokenStream, input: TokenStream) -> TokenStream {
}
}

_ => panic!("invalid attribute {:?}", path),
_ => panic!("invalid attribute {path:?}"),
},

_ => panic!("invalid argument {:?}", arg),
_ => panic!("invalid argument {arg:?}"),
}
}

Expand All @@ -318,7 +318,7 @@ pub fn serde_test(args: TokenStream, input: TokenStream) -> TokenStream {
for (i, ty) in types.into_iter().enumerate() {
let serde_test = {
let test_name = Ident::new(
&format!("test_serde_roundtrip_{}_{}", name, i),
&format!("test_serde_roundtrip_{name}_{i}"),
Span::mixed_site(),
);
quote! {
Expand All @@ -335,7 +335,7 @@ pub fn serde_test(args: TokenStream, input: TokenStream) -> TokenStream {

let zdata_test = if test_zdata {
let test_name = Ident::new(
&format!("test_zdata_roundtrip_{}_{}", name, i),
&format!("test_zdata_roundtrip_{name}_{i}"),
Span::mixed_site(),
);
quote! {
Expand Down Expand Up @@ -398,15 +398,15 @@ fn get_type_from_attrs(attrs: &[syn::Attribute], attr_name: &str) -> syn::Result
}) else {
return Err(syn::Error::new(
proc_macro2::Span::call_site(),
format!("Could not find attribute {}", attr_name),
format!("Could not find attribute {attr_name}"),
));
};

match nested_arg {
NestedMeta::Meta(Meta::Path(path)) => Ok(path),
bad => Err(syn::Error::new_spanned(
bad,
&format!("Could not parse {} attribute", attr_name)[..],
&format!("Could not parse {attr_name} attribute")[..],
)),
}
}
Expand Down Expand Up @@ -447,10 +447,7 @@ pub fn derive_try_from_repr(input: TokenStream) -> TokenStream {
match res_ty {
Err(e) => {
// If no explicit repr were given for us, we can't pursue
panic!(
"TryFromRepr macro requires a repr parameter, which couldn't be parsed: {:?}",
e
);
panic!("TryFromRepr macro requires a repr parameter, which couldn't be parsed: {e:?}");
}
Ok(ty) => {
let match_arms = try_from_match_arms(name, &variants, ty.clone());
Expand Down
5 changes: 1 addition & 4 deletions src/circuit/circuit_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5123,10 +5123,7 @@ fn car_cdr_named<F: LurkField, CS: ConstraintSystem<F>>(
maybe_cons.hash().get_value(),
&allocated_digest.get_value()
);
panic!(
"tried to take car_cdr of a non-dummy cons ({:?}) but supplied wrong value",
name
);
panic!("tried to take car_cdr of a non-dummy cons ({name:?}) but supplied wrong value");
}

implies!(cs, &cons_not_dummy, &real_cons);
Expand Down
4 changes: 2 additions & 2 deletions src/circuit/gadgets/hashes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ impl<'a, F: LurkField> AllocatedConsWitness<'a, F> {
} = &self.slots[index];
if !expect_dummy {
match allocated_name {
Err(_) => panic!("requested {:?} but found a dummy allocation", name),
Err(_) => panic!("requested {name:?} but found a dummy allocation"),
Ok(alloc_name) => assert_eq!(
name, *alloc_name,
"requested and allocated names don't match."
Expand Down Expand Up @@ -478,7 +478,7 @@ impl<'a, F: LurkField> AllocatedContWitness<'a, F> {
if !expect_dummy {
match allocated_name {
Err(_) => {
panic!("requested {:?} but found a dummy allocation", name)
panic!("requested {name:?} but found a dummy allocation")
}
Ok(alloc_name) => {
assert_eq!(
Expand Down
5 changes: 1 addition & 4 deletions src/cli/circom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@ pub(crate) fn create_circom_gadget(circom_folder: Utf8PathBuf, name: String) ->
default_field
};

println!(
"Running circom binary to generate r1cs and witness files to {:?}",
circom_gadget
);
println!("Running circom binary to generate r1cs and witness files to {circom_gadget:?}");
fs::create_dir_all(&circom_gadget)?;
let output = get_circom_binary()?
.args(&[
Expand Down
2 changes: 1 addition & 1 deletion src/cli/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ impl Repl<F> {

pub(crate) fn load_file(&mut self, file_path: &Utf8Path) -> Result<()> {
let input = read_to_string(file_path)?;
println!("Loading {}", file_path);
println!("Loading {file_path}");

let mut input = parser::Span::new(&input);
loop {
Expand Down
2 changes: 1 addition & 1 deletion src/coprocessor/circom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Then run `lurk coprocessor --name {name} <{}_FOLDER>` to instantiate a new gadge
let name = gadget.name();
let circom_folder = circom_dir().join(name);

let r1cs = circom_folder.join(format!("{}.r1cs", name));
let r1cs = circom_folder.join(format!("{name}.r1cs"));
let wasm = circom_folder.join(name).with_extension("wasm");

let config = CircomConfig::<F>::new(wasm, r1cs)?;
Expand Down
2 changes: 1 addition & 1 deletion src/eval/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<F: LurkField> Write<F> for IO<F> {

impl<F: LurkField> std::fmt::Display for IO<F> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
write!(f, "{:?}", self)
write!(f, "{self:?}")
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub trait LurkField: PrimeField + PrimeFieldBits {
let bytes = self.to_bytes();
let mut s = String::with_capacity(bytes.len() * 2);
for b in bytes.iter().rev() {
s.push_str(&format!("{:02x?}", b));
s.push_str(&format!("{b:02x?}"));
}
s
}
Expand Down
2 changes: 1 addition & 1 deletion src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl From<usize> for HashArity {
4 => Self::A4,
6 => Self::A6,
8 => Self::A8,
_ => panic!("unsupported arity: {}", n),
_ => panic!("unsupported arity: {n}"),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/lem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ impl std::fmt::Display for Tag {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
use Tag::*;
match self {
Expr(tag) => write!(f, "expr.{}", tag),
Cont(tag) => write!(f, "cont.{}", tag),
Ctrl(tag) => write!(f, "ctrl.{}", tag),
Expr(tag) => write!(f, "expr.{tag}"),
Cont(tag) => write!(f, "cont.{tag}"),
Ctrl(tag) => write!(f, "ctrl.{tag}"),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/lem/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ pub(crate) enum PathNode {
impl std::fmt::Display for PathNode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Tag(tag) => write!(f, "Tag({})", tag),
Self::Lit(lit) => write!(f, "{:?}", lit),
Self::Bool(b) => write!(f, "Bool({})", b),
Self::Tag(tag) => write!(f, "Tag({tag})"),
Self::Lit(lit) => write!(f, "{lit:?}"),
Self::Bool(b) => write!(f, "Bool({b})"),
Self::Default => write!(f, "Default"),
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/lem/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,17 +377,17 @@ impl<F: LurkField> Store<F> {
impl<F: LurkField> Ptr<F> {
pub fn dbg_display(self, store: &Store<F>) -> String {
if let Some(s) = store.fetch_string(&self) {
return format!("\"{}\"", s);
return format!("\"{s}\"");
}
if let Some(s) = store.fetch_symbol(&self) {
return format!("{}", s);
return format!("{s}");
}
match self {
Ptr::Leaf(tag, f) => {
if let Some(x) = f.to_u64() {
format!("{}{}", tag, x)
format!("{tag}{x}")
} else {
format!("{}{:?}", tag, f)
format!("{tag}{f:?}")
}
}
Ptr::Tuple2(tag, x) => {
Expand Down
6 changes: 3 additions & 3 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl<F: LurkField> Store<F> {
.parse(Span::new(input))
{
Ok((_i, x)) => Ok(self.intern_syntax(x)),
Err(e) => Err(Error::Syntax(format!("{}", e))),
Err(e) => Err(Error::Syntax(format!("{e}"))),
}
}

Expand All @@ -60,7 +60,7 @@ impl<F: LurkField> Store<F> {
.parse(Span::new(input))
{
Ok((_i, x)) => Ok(self.intern_syntax(x)),
Err(e) => Err(Error::Syntax(format!("{}", e))),
Err(e) => Err(Error::Syntax(format!("{e}"))),
}
}

Expand All @@ -73,7 +73,7 @@ impl<F: LurkField> Store<F> {
match preceded(parse_space, parse_maybe_meta(state, false)).parse(input) {
Ok((i, Some((is_meta, x)))) => Ok((i, self.intern_syntax(x), is_meta)),
Ok((_, None)) => Err(Error::NoInput),
Err(e) => Err(Error::Syntax(format!("{}", e))),
Err(e) => Err(Error::Syntax(format!("{e}"))),
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/parser/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,19 +196,19 @@ pub mod tests {
match (expected, p.parse(Span::<'a>::new(i))) {
(Some(expected), Ok((_i, x))) if x == expected => (),
(Some(expected), Ok((i, x))) => {
println!("input: {:?}", i);
println!("expected: {:?}", expected);
println!("detected: {:?}", x);
println!("input: {i:?}");
println!("expected: {expected:?}");
println!("detected: {x:?}");
unreachable!("unexpected parse result")
}
(Some(..), Err(e)) => {
println!("{}", e);
println!("{e}");
unreachable!("unexpected parse result")
}
(None, Ok((i, x))) => {
println!("input: {:?}", i);
println!("input: {i:?}");
println!("expected parse error");
println!("detected: {:?}", x);
println!("detected: {x:?}");
unreachable!("unexpected parse result")
}
(None, Err(_e)) => (),
Expand Down
12 changes: 6 additions & 6 deletions src/parser/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ impl<F: LurkField> fmt::Display for ParseErrorKind<F> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::InvalidBase16EscapeSequence(seq, _) => {
write!(f, "Unknown base 16 string escape sequence {}.", seq)
write!(f, "Unknown base 16 string escape sequence {seq}.")
}
Self::ParseIntErr(e) => {
write!(f, "Error parsing number: {}", e)
write!(f, "Error parsing number: {e}")
}
e => write!(f, "internal parser error {:?}", e),
e => write!(f, "internal parser error {e:?}"),
}
}
}
Expand Down Expand Up @@ -98,7 +98,7 @@ impl<'a, F: LurkField> fmt::Display for ParseError<Span<'a>, F> {
writeln!(&mut res, "^")?;

if let Some(exp) = self.expected {
writeln!(&mut res, "Expected {}", exp)?;
writeln!(&mut res, "Expected {exp}")?;
}

let mut errs = self.errors.iter().filter(|x| !x.is_nom_err()).peekable();
Expand All @@ -109,12 +109,12 @@ impl<'a, F: LurkField> fmt::Display for ParseError<Span<'a>, F> {
Some(_) => {
writeln!(&mut res, "Reported errors:")?;
for kind in errs {
writeln!(&mut res, "- {}", kind)?;
writeln!(&mut res, "- {kind}")?;
}
}
}

write!(f, "{}", res)
write!(f, "{res}")
}
}

Expand Down
Loading

0 comments on commit a259db1

Please sign in to comment.