Skip to content

Commit c48d83c

Browse files
committed
Clippy fixes
1 parent 599090e commit c48d83c

File tree

6 files changed

+26
-27
lines changed

6 files changed

+26
-27
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "chumsky"
3-
version = "0.10.1"
3+
version = "0.11.0"
44
description = "A parser library for humans with powerful error recovery"
55
authors = ["Joshua Barretto <joshua.s.barretto@gmail.com>", "Elijah Hartvigsen <elijah.reed@hartvigsen.xyz", "Jakob Wiesmore <runetynan@gmail.com>"]
66
repository = "https://github.com/zesterer/chumsky"

examples/json_fast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn parser<'a>() -> impl Parser<'a, &'a str, Json> {
7373
.padded()
7474
.delimited_by(just('['), just(']'));
7575

76-
let member = string.clone().then_ignore(just(':').padded()).then(value);
76+
let member = string.then_ignore(just(':').padded()).then(value);
7777
let object = member
7878
.clone()
7979
.separated_by(just(',').padded())

examples/nano_rust.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ impl fmt::Display for Token<'_> {
3131
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3232
match self {
3333
Token::Null => write!(f, "null"),
34-
Token::Bool(x) => write!(f, "{}", x),
35-
Token::Num(n) => write!(f, "{}", n),
36-
Token::Str(s) => write!(f, "{}", s),
37-
Token::Op(s) => write!(f, "{}", s),
38-
Token::Ctrl(c) => write!(f, "{}", c),
39-
Token::Ident(s) => write!(f, "{}", s),
34+
Token::Bool(x) => write!(f, "{x}"),
35+
Token::Num(n) => write!(f, "{n}"),
36+
Token::Str(s) => write!(f, "{s}"),
37+
Token::Op(s) => write!(f, "{s}"),
38+
Token::Ctrl(c) => write!(f, "{c}"),
39+
Token::Ident(s) => write!(f, "{s}"),
4040
Token::Fn => write!(f, "fn"),
4141
Token::Let => write!(f, "let"),
4242
Token::Print => write!(f, "print"),
@@ -119,7 +119,7 @@ impl Value<'_> {
119119
} else {
120120
Err(Error {
121121
span,
122-
msg: format!("'{}' is not a number", self),
122+
msg: format!("'{self}' is not a number"),
123123
})
124124
}
125125
}
@@ -129,9 +129,9 @@ impl std::fmt::Display for Value<'_> {
129129
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
130130
match self {
131131
Self::Null => write!(f, "null"),
132-
Self::Bool(x) => write!(f, "{}", x),
133-
Self::Num(x) => write!(f, "{}", x),
134-
Self::Str(x) => write!(f, "{}", x),
132+
Self::Bool(x) => write!(f, "{x}"),
133+
Self::Num(x) => write!(f, "{x}"),
134+
Self::Str(x) => write!(f, "{x}"),
135135
Self::List(xs) => write!(
136136
f,
137137
"[{}]",
@@ -140,7 +140,7 @@ impl std::fmt::Display for Value<'_> {
140140
.collect::<Vec<_>>()
141141
.join(", ")
142142
),
143-
Self::Func(name) => write!(f, "<function: {}>", name),
143+
Self::Func(name) => write!(f, "<function: {name}>"),
144144
}
145145
}
146146
}
@@ -435,7 +435,7 @@ where
435435
if funcs.insert(name, f).is_some() {
436436
emitter.emit(Rich::custom(
437437
name_span,
438-
format!("Function '{}' already exists", name),
438+
format!("Function '{name}' already exists"),
439439
));
440440
}
441441
}
@@ -470,7 +470,7 @@ fn eval_expr<'src>(
470470
.or_else(|| Some(Value::Func(name)).filter(|_| funcs.contains_key(name)))
471471
.ok_or_else(|| Error {
472472
span: expr.1,
473-
msg: format!("No such variable '{}' in scope", name),
473+
msg: format!("No such variable '{name}' in scope"),
474474
})?,
475475
Expr::Let(local, val, body) => {
476476
let val = eval_expr(val, funcs, stack)?;
@@ -509,7 +509,7 @@ fn eval_expr<'src>(
509509
let mut stack = if f.args.len() != args.0.len() {
510510
return Err(Error {
511511
span: expr.1,
512-
msg: format!("'{}' called with wrong number of arguments (expected {}, found {})", name, f.args.len(), args.0.len()),
512+
msg: format!("'{}' called with wrong number of arguments (expected {name}, found {})", f.args.len(), args.0.len()),
513513
});
514514
} else {
515515
f.args
@@ -523,7 +523,7 @@ fn eval_expr<'src>(
523523
f => {
524524
return Err(Error {
525525
span: func.1,
526-
msg: format!("'{:?}' is not callable", f),
526+
msg: format!("'{f:?}' is not callable"),
527527
})
528528
}
529529
}
@@ -536,7 +536,7 @@ fn eval_expr<'src>(
536536
c => {
537537
return Err(Error {
538538
span: cond.1,
539-
msg: format!("Conditions must be booleans, found '{:?}'", c),
539+
msg: format!("Conditions must be booleans, found '{c:?}'"),
540540
})
541541
}
542542
}
@@ -574,7 +574,7 @@ fn main() {
574574
))
575575
} else {
576576
match eval_expr(&main.body, &funcs, &mut Vec::new()) {
577-
Ok(val) => println!("Return value: {}", val),
577+
Ok(val) => println!("Return value: {val}"),
578578
Err(e) => errs.push(Rich::custom(e.span, e.msg)),
579579
}
580580
}
@@ -609,7 +609,7 @@ fn main() {
609609
)
610610
.with_labels(e.contexts().map(|(label, span)| {
611611
Label::new((filename.clone(), span.into_range()))
612-
.with_message(format!("while parsing this {}", label))
612+
.with_message(format!("while parsing this {label}"))
613613
.with_color(Color::Yellow)
614614
}))
615615
.finish()

src/combinator.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,6 @@ where
526526
go_extra!(I::Span);
527527
}
528528

529-
530529
/// See [`Parser::try_foldl`].
531530
pub struct TryFoldl<F, A, B, OB, E> {
532531
pub(crate) parser_a: A,
@@ -579,7 +578,7 @@ where
579578
Err(err) => {
580579
inp.add_alt_err(&before.inner, err);
581580
break Err(());
582-
},
581+
}
583582
}
584583
}
585584
Ok(None) => break Ok(M::bind(|| out)),

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3265,7 +3265,7 @@ mod tests {
32653265
atom.clone()
32663266
.then_ignore(just('+'))
32673267
.then(atom.clone())
3268-
.map(|(a, b)| format!("{}{}", a, b))
3268+
.map(|(a, b)| format!("{a}{b}"))
32693269
.memoized()
32703270
.or(atom)
32713271
})
@@ -3295,7 +3295,7 @@ mod tests {
32953295
.clone()
32963296
.then_ignore(just('+'))
32973297
.then(expr)
3298-
.map(|(a, b)| format!("{}{}", a, b))
3298+
.map(|(a, b)| format!("{a}{b}"))
32993299
.memoized();
33003300

33013301
sum.or(atom)
@@ -3325,7 +3325,7 @@ mod tests {
33253325
// .clone()
33263326
// .then_ignore(just('+'))
33273327
// .then(expr)
3328-
// .map(|(a, b)| format!("{}{}", a, b));
3328+
// .map(|(a, b)| format!("{a}{b}"));
33293329

33303330
// sum.or(atom)
33313331
// })
@@ -3444,7 +3444,7 @@ mod tests {
34443444
.clone()
34453445
.then_ignore(just('+'))
34463446
.then(expr.clone())
3447-
.map(|(a, b)| format!("{}{}", a, b));
3447+
.map(|(a, b)| format!("{a}{b}"));
34483448

34493449
sum.or(atom)
34503450
});

0 commit comments

Comments
 (0)