Skip to content

Commit af33a7b

Browse files
committed
Apply cargo clippy --fix
1 parent 4eab6ef commit af33a7b

File tree

9 files changed

+61
-74
lines changed

9 files changed

+61
-74
lines changed

fathom/src/core.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -672,16 +672,16 @@ pub trait UIntStyled<const N: usize>:
672672
impl UIntStyle {
673673
pub fn format<T: UIntStyled<N>, const N: usize>(&self, number: T) -> String {
674674
match self {
675-
UIntStyle::Binary => format!("0b{:b}", number),
675+
UIntStyle::Binary => format!("0b{number:b}"),
676676
UIntStyle::Decimal => number.to_string(),
677-
UIntStyle::Hexadecimal => format!("0x{:x}", number),
677+
UIntStyle::Hexadecimal => format!("0x{number:x}"),
678678
UIntStyle::Ascii => {
679679
let bytes = number.to_be_bytes();
680680
if bytes.iter().all(|c| c.is_ascii() && !c.is_ascii_control()) {
681681
let s = std::str::from_utf8(&bytes).unwrap(); // unwrap safe due to above check
682-
format!("\"{}\"", s)
682+
format!("\"{s}\"")
683683
} else {
684-
format!("0x{:x}", number)
684+
format!("0x{number:x}")
685685
}
686686
}
687687
}

fathom/src/core/binary.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ impl<'arena, 'data> Context<'arena, 'data> {
584584
// especially without succumbing to non-termination, but we'll panic
585585
// here just in case.
586586
if self.lookup_ref(pos, format).is_some() {
587-
panic!("recursion found when storing cached reference {}", pos);
587+
panic!("recursion found when storing cached reference {pos}");
588588
}
589589

590590
// Store the parsed reference in the reference cache

fathom/src/driver.rs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ impl<'surface, 'core> Driver<'surface, 'core> {
9393
};
9494

9595
let diagnostic = Diagnostic::bug()
96-
.with_message(format!("compiler panicked at '{}'", message))
96+
.with_message(format!("compiler panicked at '{message}'"))
9797
.with_notes(vec![
9898
match location {
99-
Some(location) => format!("panicked at: {}", location),
99+
Some(location) => format!("panicked at: {location}"),
100100
None => "panicked at: unknown location".to_owned(),
101101
},
102-
format!("please file a bug report at: {}", BUG_REPORT_URL),
102+
format!("please file a bug report at: {BUG_REPORT_URL}"),
103103
// TODO: print rust backtrace
104104
// TODO: print fathom backtrace
105105
]);
@@ -403,7 +403,7 @@ impl<'surface, 'core> Driver<'surface, 'core> {
403403

404404
fn emit_read_diagnostic(&self, name: impl std::fmt::Display, error: std::io::Error) {
405405
let diagnostic =
406-
Diagnostic::error().with_message(format!("couldn't read `{}`: {}", name, error));
406+
Diagnostic::error().with_message(format!("couldn't read `{name}`: {error}"));
407407
self.emit_diagnostic(diagnostic);
408408
}
409409

@@ -450,22 +450,20 @@ impl<'surface, 'core> Driver<'surface, 'core> {
450450
.with_notes(vec![format!("option_unwrap was called on a none value.")]),
451451
ReadError::BufferError(span, err) => self.buffer_error_to_diagnostic(err, span),
452452
ReadError::InvalidFormat(span) | ReadError::InvalidValue(span) => Diagnostic::bug()
453-
.with_message(format!("unexpected error '{}'", err))
453+
.with_message(format!("unexpected error '{err}'"))
454454
.with_labels(
455455
IntoIterator::into_iter([label_for_span(&span)])
456456
.into_iter()
457457
.flatten()
458458
.collect(),
459459
)
460460
.with_notes(vec![format!(
461-
"please file a bug report at: {}",
462-
BUG_REPORT_URL
461+
"please file a bug report at: {BUG_REPORT_URL}"
463462
)]),
464463
ReadError::UnknownItem => Diagnostic::bug()
465-
.with_message(format!("unexpected error '{}'", err))
464+
.with_message(format!("unexpected error '{err}'"))
466465
.with_notes(vec![format!(
467-
"please file a bug report at: {}",
468-
BUG_REPORT_URL
466+
"please file a bug report at: {BUG_REPORT_URL}"
469467
)]),
470468
}
471469
}
@@ -492,8 +490,7 @@ impl<'surface, 'core> Driver<'surface, 'core> {
492490
.collect(),
493491
)
494492
.with_notes(vec![format!(
495-
"The offset {} is before the start of the buffer.",
496-
offset
493+
"The offset {offset} is before the start of the buffer."
497494
)]),
498495
BufferError::SetOffsetAfterEndOfBuffer {
499496
offset: Some(offset),
@@ -506,8 +503,7 @@ impl<'surface, 'core> Driver<'surface, 'core> {
506503
.collect(),
507504
)
508505
.with_notes(vec![format!(
509-
"The offset {} is beyond the end of the buffer.",
510-
offset
506+
"The offset {offset} is beyond the end of the buffer."
511507
)]),
512508
BufferError::SetOffsetAfterEndOfBuffer { offset: None } => Diagnostic::error()
513509
.with_message(err.to_string())
@@ -521,16 +517,15 @@ impl<'surface, 'core> Driver<'surface, 'core> {
521517
"The offset is beyond the end of the buffer (overflow).",
522518
)]),
523519
BufferError::PositionOverflow => Diagnostic::bug()
524-
.with_message(format!("unexpected error '{}'", err))
520+
.with_message(format!("unexpected error '{err}'"))
525521
.with_labels(
526522
IntoIterator::into_iter([label_for_span(&span)])
527523
.into_iter()
528524
.flatten()
529525
.collect(),
530526
)
531527
.with_notes(vec![format!(
532-
"please file a bug report at: {}",
533-
BUG_REPORT_URL
528+
"please file a bug report at: {BUG_REPORT_URL}"
534529
)]),
535530
}
536531
}

fathom/src/env.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,11 @@ impl<Entry> SliceEnv<Entry> {
257257

258258
impl<Entry: PartialEq> SliceEnv<Entry> {
259259
pub fn elem_level(&self, entry: &Entry) -> Option<Level> {
260-
Iterator::zip(levels(), self.iter()).find_map(|(var, e)| (entry == e).then(|| var))
260+
Iterator::zip(levels(), self.iter()).find_map(|(var, e)| (entry == e).then_some(var))
261261
}
262262

263263
pub fn elem_index(&self, entry: &Entry) -> Option<Index> {
264-
Iterator::zip(indices(), self.iter().rev()).find_map(|(var, e)| (entry == e).then(|| var))
264+
Iterator::zip(indices(), self.iter().rev()).find_map(|(var, e)| (entry == e).then_some(var))
265265
}
266266
}
267267

fathom/src/source.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl StringInterner {
4747
if max_index >= len {
4848
self.tuple_labels.reserve(max_index.saturating_sub(cap));
4949
for index in len..=max_index {
50-
let label = self.get_or_intern(format!("_{}", index));
50+
let label = self.get_or_intern(format!("_{index}"));
5151
self.tuple_labels.push(label);
5252
}
5353
}

fathom/src/surface.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,11 +459,11 @@ impl ParseMessage {
459459
token,
460460
expected,
461461
} => Diagnostic::error()
462-
.with_message(format!("unexpected token {}", token))
462+
.with_message(format!("unexpected token {token}"))
463463
.with_labels(vec![primary_label(range).with_message("unexpected token")])
464464
.with_notes(format_expected(expected).map_or(Vec::new(), |message| vec![message])),
465465
ParseMessage::ExtraToken { range, token } => Diagnostic::error()
466-
.with_message(format!("extra token {}", token))
466+
.with_message(format!("extra token {token}"))
467467
.with_labels(vec![primary_label(range).with_message("extra token")]),
468468
}
469469
}
@@ -479,7 +479,7 @@ fn format_expected(expected: &[impl std::fmt::Display]) -> Option<String> {
479479
use itertools::Itertools;
480480

481481
expected.split_last().map(|items| match items {
482-
(last, []) => format!("expected {}", last),
482+
(last, []) => format!("expected {last}"),
483483
(last, expected) => format!("expected {} or {}", expected.iter().format(", "), last),
484484
})
485485
}

fathom/src/surface/elaboration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ impl<'interner, 'arena> Context<'interner, 'arena> {
457457
}
458458

459459
let filtered_fields = (fields.iter().enumerate())
460-
.filter_map(move |(index, field)| (!duplicate_indices.contains(&index)).then(|| field));
460+
.filter_map(move |(index, field)| (!duplicate_indices.contains(&index)).then_some(field));
461461

462462
(labels.into(), filtered_fields)
463463
}

fathom/src/surface/elaboration/reporting.rs

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl Message {
140140
let name = interner.resolve(*name).unwrap();
141141

142142
Diagnostic::error()
143-
.with_message(format!("cannot find `{}` in scope", name))
143+
.with_message(format!("cannot find `{name}` in scope"))
144144
.with_labels(vec![primary_label(range).with_message("unbound name")])
145145
// TODO: list suggestions
146146
}
@@ -177,7 +177,7 @@ impl Message {
177177
.with_labels(vec![
178178
primary_label(arg_range).with_message("unexpected argument"),
179179
secondary_label(head_range)
180-
.with_message(format!("expression of type {}", head_type)),
180+
.with_message(format!("expression of type {head_type}")),
181181
]),
182182
Message::UnknownField {
183183
head_range,
@@ -189,11 +189,11 @@ impl Message {
189189
let label = interner.resolve(*label).unwrap();
190190

191191
Diagnostic::error()
192-
.with_message(format!("cannot find `{}` in expression", label))
192+
.with_message(format!("cannot find `{label}` in expression"))
193193
.with_labels(vec![
194194
primary_label(label_range).with_message("unknown label"),
195195
secondary_label(head_range)
196-
.with_message(format!("expression of type {}", head_type)),
196+
.with_message(format!("expression of type {head_type}")),
197197
])
198198
// TODO: list suggestions
199199
}
@@ -213,7 +213,7 @@ impl Message {
213213
None => {
214214
let expr_label = interner.resolve(*expr_label).unwrap();
215215
diagnostic_labels.push(primary_label(range).with_message(
216-
format!("unexpected field `{}`", expr_label,),
216+
format!("unexpected field `{expr_label}`",),
217217
));
218218
continue 'expr_labels;
219219
}
@@ -224,8 +224,7 @@ impl Message {
224224
let type_label = interner.resolve(*type_label).unwrap();
225225
diagnostic_labels.push(
226226
primary_label(range).with_message(format!(
227-
"expected field `{}`",
228-
type_label,
227+
"expected field `{type_label}`",
229228
)),
230229
);
231230
continue 'type_labels;
@@ -239,7 +238,7 @@ impl Message {
239238
"missing fields {}",
240239
type_labels
241240
.map(|label| interner.resolve(*label).unwrap())
242-
.format_with(", ", |label, f| f(&format_args!("`{}`", label))),
241+
.format_with(", ", |label, f| f(&format_args!("`{label}`"))),
243242
)));
244243
} else {
245244
diagnostic_labels
@@ -249,17 +248,17 @@ impl Message {
249248

250249
let found_labels = (expr_labels.iter())
251250
.map(|(_, label)| interner.resolve(*label).unwrap())
252-
.format_with(", ", |label, f| f(&format_args!("`{}`", label)));
251+
.format_with(", ", |label, f| f(&format_args!("`{label}`")));
253252
let expected_labels = (type_labels.iter())
254253
.map(|label| interner.resolve(*label).unwrap())
255-
.format_with(", ", |label, f| f(&format_args!("`{}`", label)));
254+
.format_with(", ", |label, f| f(&format_args!("`{label}`")));
256255

257256
Diagnostic::error()
258257
.with_message("mismatched field labels in record literal")
259258
.with_labels(diagnostic_labels)
260259
.with_notes(vec![
261-
format!("expected fields {}", expected_labels),
262-
format!(" found fields {}", found_labels),
260+
format!("expected fields {expected_labels}"),
261+
format!(" found fields {found_labels}"),
263262
])
264263
}
265264
Message::DuplicateFieldLabels { range, labels } => {
@@ -278,7 +277,7 @@ impl Message {
278277
"duplicate fields {}",
279278
(labels.iter())
280279
.map(|(_, label)| interner.resolve(*label).unwrap())
281-
.format_with(", ", |label, f| f(&format_args!("`{}`", label)))
280+
.format_with(", ", |label, f| f(&format_args!("`{label}`")))
282281
)])
283282
}
284283
Message::ArrayLiteralNotSupported {
@@ -287,9 +286,9 @@ impl Message {
287286
} => Diagnostic::error()
288287
.with_message("array literal not supported")
289288
.with_labels(vec![
290-
primary_label(range).with_message(format!("expected `{}`", expected_type))
289+
primary_label(range).with_message(format!("expected `{expected_type}`"))
291290
])
292-
.with_notes(vec![format!("expected `{}`", expected_type)]),
291+
.with_notes(vec![format!("expected `{expected_type}`")]),
293292
Message::MismatchedArrayLength {
294293
range,
295294
found_len,
@@ -300,8 +299,8 @@ impl Message {
300299
primary_label(range).with_message("array with invalid length")
301300
])
302301
.with_notes(vec![
303-
format!("expected length {}", expected_len),
304-
format!(" found length {}", found_len),
302+
format!("expected length {expected_len}"),
303+
format!(" found length {found_len}"),
305304
]),
306305
Message::AmbiguousArrayLiteral { range } => Diagnostic::error()
307306
.with_message("ambiguous array literal")
@@ -318,8 +317,8 @@ impl Message {
318317
primary_label(range).with_message("invalid string literal")
319318
])
320319
.with_notes(vec![
321-
format!("expected byte length {}", expected_len),
322-
format!(" found byte length {}", found_len),
320+
format!("expected byte length {expected_len}"),
321+
format!(" found byte length {found_len}"),
323322
]),
324323
Message::NonAsciiStringLiteral { invalid_range } => Diagnostic::error()
325324
.with_message("non-ASCII character found in string literal")
@@ -332,9 +331,9 @@ impl Message {
332331
} => Diagnostic::error()
333332
.with_message("string literal not supported")
334333
.with_labels(vec![
335-
primary_label(range).with_message(format!("expected `{}`", expected_type))
334+
primary_label(range).with_message(format!("expected `{expected_type}`"))
336335
])
337-
.with_notes(vec![format!("expected `{}`", expected_type)]),
336+
.with_notes(vec![format!("expected `{expected_type}`")]),
338337
Message::AmbiguousStringLiteral { range } => Diagnostic::error()
339338
.with_message("ambiguous string literal")
340339
.with_labels(vec![
@@ -349,9 +348,9 @@ impl Message {
349348
} => Diagnostic::error()
350349
.with_message("numeric literal not supported")
351350
.with_labels(vec![
352-
primary_label(range).with_message(format!("expected `{}`", expected_type))
351+
primary_label(range).with_message(format!("expected `{expected_type}`"))
353352
])
354-
.with_notes(vec![format!("expected `{}`", expected_type)]),
353+
.with_notes(vec![format!("expected `{expected_type}`")]),
355354
Message::AmbiguousNumericLiteral { range } => Diagnostic::error()
356355
.with_message("ambiguous numeric literal")
357356
.with_labels(vec![
@@ -370,10 +369,10 @@ impl Message {
370369
} => Diagnostic::error()
371370
.with_message("mismatched types")
372371
.with_labels(vec![
373-
primary_label(lhs_range).with_message(format!("has type `{}`", lhs)),
374-
primary_label(rhs_range).with_message(format!("has type `{}`", rhs)),
372+
primary_label(lhs_range).with_message(format!("has type `{lhs}`")),
373+
primary_label(rhs_range).with_message(format!("has type `{rhs}`")),
375374
secondary_label(&op.range())
376-
.with_message(format!("no implementation for `{} {} {}`", lhs, op, rhs)),
375+
.with_message(format!("no implementation for `{lhs} {op} {rhs}`")),
377376
]),
378377
Message::FailedToUnify {
379378
range,
@@ -388,12 +387,11 @@ impl Message {
388387
Error::Mismatch => Diagnostic::error()
389388
.with_message("mismatched types")
390389
.with_labels(vec![primary_label(range).with_message(format!(
391-
"type mismatch, expected `{}`, found `{}`",
392-
lhs, rhs
390+
"type mismatch, expected `{lhs}`, found `{rhs}`"
393391
))])
394392
.with_notes(vec![[
395-
format!("expected `{}`", lhs),
396-
format!(" found `{}`", rhs),
393+
format!("expected `{lhs}`"),
394+
format!(" found `{rhs}`"),
397395
]
398396
.join("\n")]),
399397
// TODO: reduce confusion around ‘problem spines’
@@ -426,11 +424,10 @@ impl Message {
426424
let name = interner.resolve(*name).unwrap();
427425

428426
Diagnostic::note()
429-
.with_message(format!("solution found for hole `?{}`", name))
427+
.with_message(format!("solution found for hole `?{name}`"))
430428
.with_labels(vec![primary_label(range).with_message("solution found")])
431429
.with_notes(vec![format!(
432-
"hole `?{}` can be replaced with `{}`",
433-
name, expr,
430+
"hole `?{name}` can be replaced with `{expr}`",
434431
)])
435432
}
436433
Message::UnsolvedMetaVar { source } => {
@@ -448,9 +445,9 @@ impl Message {
448445
};
449446

450447
Diagnostic::error()
451-
.with_message(format!("failed to infer {}", source_name))
448+
.with_message(format!("failed to infer {source_name}"))
452449
.with_labels(vec![
453-
primary_label(range).with_message(format!("unsolved {}", source_name))
450+
primary_label(range).with_message(format!("unsolved {source_name}"))
454451
])
455452
}
456453
Message::CycleDetected { names } => {
@@ -468,8 +465,7 @@ impl Message {
468465
.with_message("produced core term without span")
469466
.with_labels(vec![primary_label(range)])
470467
.with_notes(vec![format!(
471-
"please file a bug report at: {}",
472-
BUG_REPORT_URL
468+
"please file a bug report at: {BUG_REPORT_URL}"
473469
)]),
474470
}
475471
}

0 commit comments

Comments
 (0)