Skip to content

Commit 4840231

Browse files
committed
cargo clippy fix
1 parent a612d4d commit 4840231

File tree

24 files changed

+188
-211
lines changed

24 files changed

+188
-211
lines changed

build.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::path::Path;
77
// this is aimed to have an UI with a single binary distribution.
88
fn main() {
99
let ui_dir = "ui";
10-
println!("cargo:rerun-if-changed={}", ui_dir);
10+
println!("cargo:rerun-if-changed={ui_dir}");
1111
println!("cargo:rerun-if-changed=build.rs");
1212
gen_embedded_ui(ui_dir);
1313
}
@@ -24,10 +24,10 @@ fn gen_embedded_ui(base: &str) {
2424
format!(
2525
r#"
2626
#[allow(dead_code)]
27-
async fn get_{id}() -> impl IntoResponse {{
27+
async fn get_{id}() -> impl IntoResponse {{
2828
const BYTES: &[u8] = include_bytes!(r"{fname}");
2929
let header = [(header::CONTENT_TYPE, "{mime}")];
30-
(header,BYTES)
30+
(header,BYTES)
3131
}}"#,
3232
id = escape_name(name),
3333
//name = Path::new(name).file_name().unwrap().to_str().unwrap(),
@@ -71,9 +71,7 @@ pub fn app() -> Router {{
7171
{routes}
7272
}}
7373
{resources}
74-
"#,
75-
routes = routes,
76-
resources = resources
74+
"#
7775
),
7876
)
7977
.unwrap();

milu/examples/repl.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ async fn repl() -> rustyline::Result<()> {
150150
let mut buf = vec![];
151151
let global: ScriptContextRef = Default::default();
152152
loop {
153-
let p = format!("{}> ", count);
154-
rl.helper_mut().expect("No helper").colored_prompt = format!("\x1b[1;32m{}\x1b[0m", p);
153+
let p = format!("{count}> ");
154+
rl.helper_mut().expect("No helper").colored_prompt = format!("\x1b[1;32m{p}\x1b[0m");
155155
let readline = rl.readline(&p);
156156
match readline {
157157
Ok(line) => {
@@ -162,7 +162,7 @@ async fn repl() -> rustyline::Result<()> {
162162
let sbuf = buf.join(" ");
163163
eval(ctx, &sbuf).await; // Added await
164164
if let Err(e) = rl.add_history_entry(&sbuf) {
165-
eprintln!("Failed to add history entry: {}", e);
165+
eprintln!("Failed to add history entry: {e}");
166166
}
167167
count += 1;
168168
buf.clear();
@@ -177,7 +177,7 @@ async fn repl() -> rustyline::Result<()> {
177177
break;
178178
}
179179
Err(err) => {
180-
eprintln!("Error: {:?}", err);
180+
eprintln!("Error: {err:?}");
181181
break;
182182
}
183183
}
@@ -190,22 +190,22 @@ async fn eval(ctx: ScriptContextRef, str: &str) -> bool {
190190
// Added async
191191
let val_parse_result = parser::parse(str); // Renamed to avoid conflict
192192
if let Err(e) = val_parse_result {
193-
eprintln!("parser error: {}", e);
193+
eprintln!("parser error: {e}");
194194
return false;
195195
}
196196
let parsed_val = val_parse_result.unwrap(); // Renamed to avoid conflict
197197
let typ_result = parsed_val.type_of(ctx.clone()).await; // Renamed to avoid conflict
198198
if let Err(e) = typ_result {
199-
eprintln!("type inference error: {}", e);
199+
eprintln!("type inference error: {e}");
200200
return false;
201201
}
202202
let eval_result = parsed_val.value_of(ctx).await; // Added await, renamed
203203
if let Err(e) = eval_result {
204-
eprintln!("eval error: {}", e);
204+
eprintln!("eval error: {e}");
205205
return false;
206206
}
207207
let final_val = eval_result.unwrap(); // Renamed to avoid conflict
208208
let final_typ = typ_result.unwrap(); // Renamed to avoid conflict
209-
println!("{} : {}", final_val, final_typ);
209+
println!("{final_val} : {final_typ}");
210210
true
211211
}

milu/src/parser/rules.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ pub fn parse_many(op: Span, mut args: Vec<Value>) -> Value {
4040
Access::make_call(p1, p2).into()
4141
}
4242
_ => panic!(
43-
"impossible: unsupported operation '{}' reached parser - this indicates a parser bug",
44-
op
43+
"impossible: unsupported operation '{op}' reached parser - this indicates a parser bug"
4544
),
4645
}
4746
}
@@ -53,8 +52,7 @@ pub fn parse1(op: Span, p1: Value) -> Value {
5352
"~" => BitNot::make_call(p1).into(),
5453
"-" => Negative::make_call(p1).into(),
5554
_ => panic!(
56-
"impossible: unsupported unary operation '{}' reached parser - this indicates a parser bug",
57-
op
55+
"impossible: unsupported unary operation '{op}' reached parser - this indicates a parser bug"
5856
),
5957
}
6058
}
@@ -95,8 +93,7 @@ pub fn parse2(op: Span, p1: Value, p2: Value) -> Value {
9593
//prioity 1
9694
"||" | "or" => Or::make_call(p1, p2).into(),
9795
_ => panic!(
98-
"impossible: unsupported binary operation '{}' reached parser - this indicates a parser bug",
99-
op
96+
"impossible: unsupported binary operation '{op}' reached parser - this indicates a parser bug"
10097
),
10198
}
10299
}

milu/src/parser/string.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,15 @@ mod tests {
177177
#[test]
178178
fn test_parse_string() {
179179
let data = Span::new("\"abc\"");
180-
println!("EXAMPLE 1:\nParsing a simple input string: {}", data);
180+
println!("EXAMPLE 1:\nParsing a simple input string: {data}");
181181
let result = parse_string::<()>(data).unwrap().1;
182182
assert_eq!(result, String::from("abc"));
183-
println!("Result: {}\n\n", result);
183+
println!("Result: {result}\n\n");
184184
let data = Span::new(
185185
"\"tab:\\tafter tab, newline:\\nnew line, quote: \\\", emoji: \\u{1F602}, newline:\\nescaped whitespace: \\ abc\"",
186186
);
187187
println!(
188-
"EXAMPLE 2:\nParsing a string with escape sequences, newline literal, and escaped whitespace:\n\n{}\n",
189-
data
188+
"EXAMPLE 2:\nParsing a string with escape sequences, newline literal, and escaped whitespace:\n\n{data}\n"
190189
);
191190
let result = parse_string::<()>(data).unwrap().1;
192191
assert_eq!(
@@ -195,7 +194,7 @@ mod tests {
195194
"tab:\tafter tab, newline:\nnew line, quote: \", emoji: 😂, newline:\nescaped whitespace: abc"
196195
)
197196
);
198-
println!("Result:\n\n{}", result);
197+
println!("Result:\n\n{result}");
199198
}
200199

201200
// Helper for error tests

milu/src/parser/template.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ mod tests {
138138
// If tests create Spans, they should use the same type.
139139
let span_input = ParserSpan::new(input); // Use the aliased Span from parser
140140
let result = parse_template::<nom_language::error::VerboseError<ParserSpan>>(span_input);
141-
assert!(result.is_ok(), "Parsing failed for input: {}", input);
141+
assert!(result.is_ok(), "Parsing failed for input: {input}");
142142
let (_, parsed_vec) = result.unwrap();
143143

144144
let expected_value = if parsed_vec.is_empty() {
@@ -158,13 +158,12 @@ mod tests {
158158

159159
assert_eq!(
160160
actual_value_from_parser, expected_value,
161-
"Mismatch for input: {}",
162-
input
161+
"Mismatch for input: {input}"
163162
);
164163
}
165164

166165
fn assert_parse_template_error(input: &str) {
167-
assert!(parse(input).is_err(), "Expected error for input: {}", input);
166+
assert!(parse(input).is_err(), "Expected error for input: {input}");
168167
}
169168

170169
#[test]

milu/src/parser/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::sync::Arc;
88
#[inline]
99
fn assert_ast(input: &str, value: Value) {
1010
let output = parse(input);
11-
println!("input={}\noutput={:?}", input, output);
11+
println!("input={input}\noutput={output:?}");
1212
assert_eq!(output.unwrap(), value);
1313
}
1414

milu/src/script/stdlib/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function!(ToString(s: Any)=>String, {
153153
function!(ToInteger(s: String)=>Integer, {
154154
let s_val:String = s.try_into()?;
155155
s_val.parse::<i64>().map(Into::into)
156-
.context(format!("failed to parse integer: {}", s_val))
156+
.context(format!("failed to parse integer: {s_val}"))
157157
});
158158

159159
function_head!(IsMemberOf(a: Any, ary: Type::array_of(Type::Any)) => Boolean);

milu/src/script/tests.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ macro_rules! assert_eval_and_type {
7878

7979
async fn type_test(input: &str, output: Type) {
8080
let ctx = ScriptContext::default_ref(); // Use helper for ScriptContextRef
81-
let parsed_value =
82-
parse(input).unwrap_or_else(|e| panic!("Parse error for '{}': {:?}", input, e));
81+
let parsed_value = parse(input).unwrap_or_else(|e| panic!("Parse error for '{input}': {e:?}"));
8382
let value_type = parsed_value.type_of(ctx).await.unwrap();
8483
assert_eq!(value_type, output);
8584
}
@@ -132,8 +131,7 @@ fn unresovled_ids() {
132131
value.unresovled_ids(&mut unresovled_ids);
133132
assert!(
134133
unresovled_ids.is_empty(),
135-
"Test 1 failed: expected empty, got {:?}",
136-
unresovled_ids
134+
"Test 1 failed: expected empty, got {unresovled_ids:?}"
137135
);
138136

139137
let value = parse("let a=1;b=a+1 in a+b+c").unwrap();

milu/src/script/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl Display for Type {
4545
Self::String => write!(f, "string"),
4646
Self::Integer => write!(f, "integer"),
4747
Self::Boolean => write!(f, "boolean"),
48-
Self::Array(a) => write!(f, "[{}]", a),
48+
Self::Array(a) => write!(f, "[{a}]"),
4949
Self::Tuple(t) => write!(
5050
f,
5151
"({})",

milu/src/script/value.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,11 @@ impl Display for Value {
196196
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
197197
use Value::*;
198198
match self {
199-
String(s) => write!(f, "{:?}", s),
200-
Integer(i) => write!(f, "{}", i),
201-
Boolean(b) => write!(f, "{}", b),
202-
Identifier(id) => write!(f, "<{}>", id),
203-
OpCall(x) => write!(f, "{}", x),
199+
String(s) => write!(f, "{s:?}"),
200+
Integer(i) => write!(f, "{i}"),
201+
Boolean(b) => write!(f, "{b}"),
202+
Identifier(id) => write!(f, "<{id}>"),
203+
OpCall(x) => write!(f, "{x}"),
204204
Array(x) => write!(
205205
f,
206206
"[{}]",
@@ -217,7 +217,7 @@ impl Display for Value {
217217
.collect::<Vec<_>>()
218218
.join(",")
219219
),
220-
NativeObject(x) => write!(f, "{:?}", x),
220+
NativeObject(x) => write!(f, "{x:?}"),
221221
Function(x) => {
222222
let name = x.name.as_deref().unwrap_or("");
223223
write!(f, "fn<{}>({})", name, x.arg_names.join(", "))

0 commit comments

Comments
 (0)