]> Repositorios git - scryer-prolog.git/commitdiff
fix clippy::uninlined_format_args
authorBennet Bleßmann <[email protected]>
Thu, 31 Jul 2025 19:26:08 +0000 (21:26 +0200)
committerBennet Bleßmann <[email protected]>
Thu, 31 Jul 2025 19:26:08 +0000 (21:26 +0200)
build/instructions_template.rs
build/static_string_indexing.rs
src/forms.rs
src/functor_macro.rs
src/heap_print.rs
src/machine/loader.rs
src/machine/machine_indices.rs
src/machine/mock_wam.rs
src/machine/system_calls.rs
src/parser/ast.rs

index dc2ed9f7710cb1e4d9f5d3ffc4729ba688aaf876..2f760ea1549816a272d4c1d46613e7248d532d73 100644 (file)
@@ -3262,14 +3262,14 @@ where
     let disc = match DiscriminantT::from_str(id.to_string().as_str()) {
         Ok(disc) => disc,
         Err(_) => {
-            panic!("can't generate discriminant {}", id);
+            panic!("can't generate discriminant {id}");
         }
     };
 
     match disc.get_str(key) {
         Some(prop) => prop,
         None => {
-            panic!("can't find property {} of discriminant {:?}", key, disc);
+            panic!("can't find property {key} of discriminant {disc:?}");
         }
     }
 }
@@ -3387,7 +3387,7 @@ impl InstructionData {
 
             (name, arity, CountableInference::HasDefault)
         } else {
-            panic!("type ID is: {}", id);
+            panic!("type ID is: {id}");
         };
 
         let v_ident = variant
index bffb5c13b60a94a7ff53d3bc4e3abc046788f5e8..a577a51745064c136bc3f7a44cbf2553ddd480f2 100644 (file)
@@ -126,14 +126,14 @@ pub fn index_static_strings(instruction_rs_path: &std::path::Path) -> TokenStrea
         match file.read_to_string(&mut src) {
             Ok(_) => {}
             Err(e) => {
-                panic!("error reading file: {:?}", e);
+                panic!("error reading file: {e:?}");
             }
         }
 
         let syntax = match syn::parse_file(&src) {
             Ok(s) => s,
             Err(e) => {
-                panic!("parse error: {} in file {:?}", e, path);
+                panic!("parse error: {e} in file {path:?}");
             }
         };
         Ok(syntax)
index 1418b5701047ba416803e9ea5b286868af2fcadb..409da51ee21b6ffa85966d43d9200e2ec55bc576 100644 (file)
@@ -627,9 +627,9 @@ impl Default for Number {
 impl fmt::Display for Number {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self {
-            Number::Float(fl) => write!(f, "{}", fl),
-            Number::Integer(n) => write!(f, "{}", n),
-            Number::Rational(r) => write!(f, "{}", r),
+            Number::Float(fl) => write!(f, "{fl}"),
+            Number::Integer(n) => write!(f, "{n}"),
+            Number::Rational(r) => write!(f, "{r}"),
             Number::Fixnum(n) => write!(f, "{}", n.get_num()),
         }
     }
index ba19f682e514378c3221d8462d714a19fdb1e8f1..54bcb28ce740fced44fed9d01ccd5a7fdc66f3a9 100644 (file)
@@ -739,12 +739,12 @@ mod tests {
             ]
         );
 
-        println!("{:?}", stub);
+        println!("{stub:?}");
 
         // now the error form
         let lineless_error_form = functor!(atom!("error"), [functor(stub), functor(culprit)]);
 
-        println!("{:?}", lineless_error_form);
+        println!("{lineless_error_form:?}");
 
         let mut heap = Heap::new();
         let mut functor_writer = Heap::functor_writer(lineless_error_form);
index 9cc3a2d00e7718ddf12d3f7a6ab2e632810f0386..57fef89557435d74ce4a8c3fec80d3b5b757de60 100644 (file)
@@ -831,13 +831,13 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
 
         read_heap_cell!(cell,
             (HeapCellValueTag::Lis | HeapCellValueTag::Str, h) => {
-                Some(format!("{}", h))
+                Some(format!("{h}"))
             }
             (HeapCellValueTag::Var | HeapCellValueTag::AttrVar, h) => {
-                Some(format!("_{}", h))
+                Some(format!("_{h}"))
             }
             (HeapCellValueTag::StackVar, h) => {
-                Some(format!("_s_{}", h))
+                Some(format!("_s_{h}"))
             }
             _ => {
                 None
@@ -1002,7 +1002,7 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
     #[inline]
     fn print_ip_addr(&mut self, ip: IpAddr) {
         push_char!(self, '\'');
-        append_str!(self, &format!("{}", ip));
+        append_str!(self, &format!("{ip}"));
         push_char!(self, '\'');
     }
 
@@ -1039,7 +1039,7 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
                     self.print_rational(max_depth, r, *op);
                 }
                 n => {
-                    let output_str = format!("{}", n);
+                    let output_str = format!("{n}");
 
                     push_space_if_amb!(self, &output_str, {
                         append_str!(self, &output_str);
@@ -1086,7 +1086,7 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
         match self.op_dir.get(&(atom!("rdiv"), Fixity::In)) {
             Some(op_desc) => {
                 if r.is_int() {
-                    let output_str = format!("{}", r);
+                    let output_str = format!("{r}");
 
                     push_space_if_amb!(self, &output_str, {
                         append_str!(self, &output_str);
index 685a69a0532574903ed2044693f64b94ed82ef4a..08282f6811514370aac11d71c594af9fad13909a 100644 (file)
@@ -1407,10 +1407,10 @@ impl MachineState {
                     term_stack.push(Term::Literal(Cell::default(), Literal::try_from(addr).unwrap()));
                 }
                 (HeapCellValueTag::StackVar, h) => {
-                    term_stack.push(Term::Var(Cell::default(), VarPtr::from(format!("s_{}", h))));
+                    term_stack.push(Term::Var(Cell::default(), VarPtr::from(format!("s_{h}"))));
                 }
                 (HeapCellValueTag::Var | HeapCellValueTag::AttrVar, h) => {
-                    term_stack.push(Term::Var(Cell::default(), VarPtr::from(format!("_{}", h))));
+                    term_stack.push(Term::Var(Cell::default(), VarPtr::from(format!("_{h}"))));
                 }
                 (HeapCellValueTag::Atom, (name, arity)) => {
                     let h = iter.focus().value() as usize;
index 4f04c2b182509e256f98552815111062b180068f..07d77f6a36496f541edfe682312345265420ab4e 100644 (file)
@@ -206,7 +206,7 @@ impl VarKey {
     #[inline]
     pub(crate) fn to_string(&self) -> String {
         match self {
-            VarKey::AnonVar(h) => format!("_{}", h),
+            VarKey::AnonVar(h) => format!("_{h}"),
             VarKey::VarPtr(var) => var.borrow().to_string(),
         }
     }
index b7201b716a5f7f2a3991ced14903a83b94da3c4f..941ff81ebbd88ee848e05c8595e6367551f17a76 100644 (file)
@@ -195,15 +195,11 @@ pub fn all_cells_marked_and_unforwarded(heap: &Heap, offset: usize) {
 
         assert!(
             cell.get_mark_bit(),
-            "cell {:?} at index {} is not marked",
-            cell,
-            curr_idx
+            "cell {cell:?} at index {curr_idx} is not marked"
         );
         assert!(
             !cell.get_forwarding_bit(),
-            "cell {:?} at index {} is forwarded",
-            cell,
-            curr_idx
+            "cell {cell:?} at index {curr_idx} is forwarded"
         );
     }
 }
@@ -227,9 +223,7 @@ pub fn all_cells_unmarked(iter: &impl SizedHeap) {
 
         assert!(
             !cell.get_mark_bit(),
-            "cell {:?} at index {} is still marked",
-            cell,
-            curr_idx
+            "cell {cell:?} at index {curr_idx} is still marked"
         );
     }
 }
index 6c861ae69d15ba945f51f6492694cd50c1610627..244d56afe05b216fc7729897e0189883ef092c82 100644 (file)
@@ -2916,7 +2916,7 @@ impl Machine {
 
         let string = match Number::try_from((n, &self.machine_st.arena.f64_tbl)) {
             Ok(Number::Float(OrderedFloat(n))) => {
-                format!("{0:<20?}", n)
+                format!("{n:<20?}")
             }
             Ok(Number::Fixnum(n)) => n.get_num().to_string(),
             Ok(Number::Integer(n)) => n.to_string(),
@@ -3245,7 +3245,7 @@ impl Machine {
                     let n: u32 = (&*n).try_into().unwrap();
                     let n = char::try_from(n);
                     if let Ok(c) = n {
-                        write!(&mut stream, "{}", c).unwrap();
+                        write!(&mut stream, "{c}").unwrap();
                         return Ok(());
                     }
                 }
@@ -3253,7 +3253,7 @@ impl Machine {
                     let n = n.get_num();
 
                     if let Some(c) = u32::try_from(n).ok().and_then(char::from_u32) {
-                        write!(&mut stream, "{}", c).unwrap();
+                        write!(&mut stream, "{c}").unwrap();
                         return Ok(());
                     }
                 }
@@ -3295,13 +3295,13 @@ impl Machine {
             read_heap_cell!(addr,
                 (HeapCellValueTag::Atom, (name, _arity)) => {
                     if let Some(c) = name.as_char() {
-                        write!(&mut stream, "{}", c).unwrap();
+                        write!(&mut stream, "{c}").unwrap();
                         return Ok(());
                     }
                 }
                 /*
                 (HeapCellValueTag::Char, c) => {
-                    write!(&mut stream, "{}", c).unwrap();
+                    write!(&mut stream, "{c}").unwrap();
                     return Ok(());
                 }
                 */
@@ -8622,7 +8622,7 @@ impl Machine {
         ];
 
         for spec in SPECIFIERS {
-            fstr.push_str(&format!("'{}'=\"%{}\", ", spec, spec).to_string());
+            fstr.push_str(&format!("'{spec}'=\"%{spec}\", "));
         }
 
         fstr.push_str("finis].");
index aa9ea077281aa2cf007d235a58f243751500629c..654b290131f4788989d75eae0b264ed4967be150 100644 (file)
@@ -268,8 +268,8 @@ impl RegType {
 impl fmt::Display for RegType {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self {
-            RegType::Perm(val) => write!(f, "Y{}", val),
-            RegType::Temp(val) => write!(f, "X{}", val),
+            RegType::Perm(val) => write!(f, "Y{val}"),
+            RegType::Temp(val) => write!(f, "X{val}"),
         }
     }
 }
@@ -291,10 +291,10 @@ impl VarReg {
 impl fmt::Display for VarReg {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self {
-            VarReg::Norm(RegType::Perm(reg)) => write!(f, "Y{}", reg),
-            VarReg::Norm(RegType::Temp(reg)) => write!(f, "X{}", reg),
-            VarReg::ArgAndNorm(RegType::Perm(reg), arg) => write!(f, "Y{} A{}", reg, arg),
-            VarReg::ArgAndNorm(RegType::Temp(reg), arg) => write!(f, "X{} A{}", reg, arg),
+            VarReg::Norm(RegType::Perm(reg)) => write!(f, "Y{reg}"),
+            VarReg::Norm(RegType::Temp(reg)) => write!(f, "X{reg}"),
+            VarReg::ArgAndNorm(RegType::Perm(reg), arg) => write!(f, "Y{reg} A{arg}"),
+            VarReg::ArgAndNorm(RegType::Temp(reg), arg) => write!(f, "X{reg} A{arg}"),
         }
     }
 }
@@ -830,7 +830,7 @@ impl Var {
     #[inline(always)]
     pub fn to_string(&self) -> String {
         match self {
-            Var::InSitu(n) | Var::Generated(n) => format!("_{}", n),
+            Var::InSitu(n) | Var::Generated(n) => format!("_{n}"),
             Var::Named(value) => value.as_ref().clone(),
         }
     }