Skip to content

Commit d7dcaa0

Browse files
abhillmanjamesyoungman
authored andcommitted
rust fmt
``` $ cargo fmt --version rustfmt 1.8.0 ```
1 parent 90682cb commit d7dcaa0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+468
-306
lines changed

assembler/src/asmlib/ast.rs

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ use std::fmt::{self, Display, Formatter, Octal, Write};
1919
use std::hash::Hash;
2020
use std::ops::{Shl, Shr};
2121

22-
use tracing::{event, Level};
22+
use tracing::{Level, event};
2323

24-
use base::charset::{subscript_char, superscript_char, Script};
24+
use base::charset::{Script, subscript_char, superscript_char};
2525
use base::prelude::*;
2626
use base::u18;
2727

2828
use super::collections::OneOrMore;
2929
use super::eval::{
30-
symbol_name_lookup, Evaluate, EvaluationContext, HereValue, SymbolLookupFailure,
30+
Evaluate, EvaluationContext, HereValue, SymbolLookupFailure, symbol_name_lookup,
3131
};
3232
use super::glyph;
3333
use super::listing::{Listing, ListingLine};
@@ -40,9 +40,9 @@ use super::source::Source;
4040
use super::span::*;
4141
use super::symbol::{InconsistentSymbolUse, SymbolContext, SymbolName};
4242
use super::symtab::{
43-
record_undefined_symbol_or_return_failure, BadSymbolDefinition, ExplicitDefinition,
44-
ExplicitSymbolTable, FinalSymbolDefinition, FinalSymbolTable, FinalSymbolType,
45-
ImplicitSymbolTable, IndexRegisterAssigner, TagDefinition,
43+
BadSymbolDefinition, ExplicitDefinition, ExplicitSymbolTable, FinalSymbolDefinition,
44+
FinalSymbolTable, FinalSymbolType, ImplicitSymbolTable, IndexRegisterAssigner, TagDefinition,
45+
record_undefined_symbol_or_return_failure,
4646
};
4747
use super::types::*;
4848
mod eval;
@@ -201,7 +201,8 @@ impl SignedAtom {
201201
&self,
202202
block_id: BlockIdentifier,
203203
block_offset: Unsigned18Bit,
204-
) -> impl Iterator<Item = Result<(SymbolName, Span, SymbolUse), InconsistentSymbolUse>> + use<> {
204+
) -> impl Iterator<Item = Result<(SymbolName, Span, SymbolUse), InconsistentSymbolUse>> + use<>
205+
{
205206
self.magnitude.symbol_uses(block_id, block_offset)
206207
}
207208

@@ -308,7 +309,8 @@ impl ArithmeticExpression {
308309
&self,
309310
block_id: BlockIdentifier,
310311
block_offset: Unsigned18Bit,
311-
) -> impl Iterator<Item = Result<(SymbolName, Span, SymbolUse), InconsistentSymbolUse>> + use<> {
312+
) -> impl Iterator<Item = Result<(SymbolName, Span, SymbolUse), InconsistentSymbolUse>> + use<>
313+
{
312314
let mut result = Vec::with_capacity(1 + self.tail.len());
313315
result.extend(self.first.symbol_uses(block_id, block_offset));
314316
result.extend(
@@ -339,7 +341,9 @@ impl ArithmeticExpression {
339341
Operator::Subtract => match left.checked_sub(right) {
340342
Some(result) => result,
341343
None => {
342-
todo!("subtraction overflow occurred in {left}-{right} but this is not implemented")
344+
todo!(
345+
"subtraction overflow occurred in {left}-{right} but this is not implemented"
346+
)
343347
}
344348
},
345349
Operator::Multiply => match left.checked_mul(right) {
@@ -445,7 +449,8 @@ impl ConfigValue {
445449
&self,
446450
block_id: BlockIdentifier,
447451
block_offset: Unsigned18Bit,
448-
) -> impl Iterator<Item = Result<(SymbolName, Span, SymbolUse), InconsistentSymbolUse>> + use<> {
452+
) -> impl Iterator<Item = Result<(SymbolName, Span, SymbolUse), InconsistentSymbolUse>> + use<>
453+
{
449454
self.expr
450455
.symbol_uses(block_id, block_offset)
451456
.map(|r| match r {
@@ -578,7 +583,9 @@ impl Spanned for RegistersContaining {
578583
match it.next() {
579584
Some(rc) => it.fold(rc.span(), |acc, rc| acc.union(rc.span())),
580585
None => {
581-
unreachable!("invariant broken: RegistersContaining contains no RegisterContaining instances")
586+
unreachable!(
587+
"invariant broken: RegistersContaining contains no RegisterContaining instances"
588+
)
582589
}
583590
}
584591
}
@@ -638,7 +645,9 @@ impl RegisterContaining {
638645
// words.
639646
}
640647
SymbolUse::Definition(ExplicitDefinition::Origin(_, _)) => {
641-
unreachable!("Found origin {name} inside an RC-word; the parser should have rejected this.");
648+
unreachable!(
649+
"Found origin {name} inside an RC-word; the parser should have rejected this."
650+
);
642651
}
643652
SymbolUse::Definition(_) => {
644653
// e.g. we have an input like
@@ -655,7 +664,9 @@ impl RegisterContaining {
655664
// When working on this case we should
656665
// figure out if an equality is allowed
657666
// inside a macro expansion.
658-
panic!("Found unexpected definition of {name} inside RC-word reference at {span:?}");
667+
panic!(
668+
"Found unexpected definition of {name} inside RC-word reference at {span:?}"
669+
);
659670
}
660671
}
661672
}
@@ -776,7 +787,8 @@ impl Atom {
776787
&self,
777788
block_id: BlockIdentifier,
778789
block_offset: Unsigned18Bit,
779-
) -> impl Iterator<Item = Result<(SymbolName, Span, SymbolUse), InconsistentSymbolUse>> + use<> {
790+
) -> impl Iterator<Item = Result<(SymbolName, Span, SymbolUse), InconsistentSymbolUse>> + use<>
791+
{
780792
let mut result: Vec<Result<_, _>> = Vec::with_capacity(1);
781793
match self {
782794
Atom::SymbolOrLiteral(SymbolOrLiteral::Symbol(script, name, span)) => {
@@ -933,7 +945,8 @@ pub(crate) enum SymbolOrLiteral {
933945
impl SymbolOrLiteral {
934946
fn symbol_uses(
935947
&self,
936-
) -> impl Iterator<Item = Result<(SymbolName, Span, SymbolUse), InconsistentSymbolUse>> + use<> {
948+
) -> impl Iterator<Item = Result<(SymbolName, Span, SymbolUse), InconsistentSymbolUse>> + use<>
949+
{
937950
let mut result = Vec::with_capacity(1);
938951
match self {
939952
SymbolOrLiteral::Here(_, _) | SymbolOrLiteral::Literal(_) => (),
@@ -1101,7 +1114,8 @@ impl InstructionFragment {
11011114
&self,
11021115
block_id: BlockIdentifier,
11031116
block_offset: Unsigned18Bit,
1104-
) -> impl Iterator<Item = Result<(SymbolName, Span, SymbolUse), InconsistentSymbolUse>> + use<> {
1117+
) -> impl Iterator<Item = Result<(SymbolName, Span, SymbolUse), InconsistentSymbolUse>> + use<>
1118+
{
11051119
let mut uses: Vec<Result<(SymbolName, Span, SymbolUse), InconsistentSymbolUse>> =
11061120
Vec::new();
11071121
match self {
@@ -1172,7 +1186,9 @@ impl InstructionFragment {
11721186
rc_word_value,
11731187
}),
11741188
SymbolSubstitution::Hit(_span, _script, _arithmetic_expression) => {
1175-
todo!("macro parameter expansion is not yet fully supported in the index part of pipe constructs")
1189+
todo!(
1190+
"macro parameter expansion is not yet fully supported in the index part of pipe constructs"
1191+
)
11761192
}
11771193
SymbolSubstitution::Omit => None,
11781194
SymbolSubstitution::Zero(span) => Some(InstructionFragment::Null(span)),
@@ -1282,7 +1298,8 @@ impl Origin {
12821298
pub(super) fn symbol_uses(
12831299
&self,
12841300
block_id: BlockIdentifier,
1285-
) -> impl Iterator<Item = Result<(SymbolName, Span, SymbolUse), InconsistentSymbolUse>> + use<> {
1301+
) -> impl Iterator<Item = Result<(SymbolName, Span, SymbolUse), InconsistentSymbolUse>> + use<>
1302+
{
12861303
let mut result = Vec::with_capacity(1);
12871304
match self {
12881305
Origin::Literal(_span, _) => (),
@@ -1581,7 +1598,8 @@ impl Tag {
15811598
&self,
15821599
block_id: BlockIdentifier,
15831600
block_offset: Unsigned18Bit,
1584-
) -> impl Iterator<Item = Result<(SymbolName, Span, SymbolUse), InconsistentSymbolUse>> + use<> {
1601+
) -> impl Iterator<Item = Result<(SymbolName, Span, SymbolUse), InconsistentSymbolUse>> + use<>
1602+
{
15851603
[Ok((
15861604
self.name.clone(),
15871605
self.span,
@@ -1621,7 +1639,8 @@ impl TaggedProgramInstruction {
16211639
&self,
16221640
block_id: BlockIdentifier,
16231641
offset: Unsigned18Bit,
1624-
) -> impl Iterator<Item = Result<(SymbolName, Span, SymbolUse), InconsistentSymbolUse>> + use<> {
1642+
) -> impl Iterator<Item = Result<(SymbolName, Span, SymbolUse), InconsistentSymbolUse>> + use<>
1643+
{
16251644
let mut result: Vec<Result<_, _>> = Vec::new();
16261645
result.extend(
16271646
self.tags
@@ -1809,7 +1828,8 @@ impl InstructionSequence {
18091828
pub(crate) fn symbol_uses(
18101829
&self,
18111830
block_id: BlockIdentifier,
1812-
) -> impl Iterator<Item = Result<(SymbolName, Span, SymbolUse), InconsistentSymbolUse>> + use<> {
1831+
) -> impl Iterator<Item = Result<(SymbolName, Span, SymbolUse), InconsistentSymbolUse>> + use<>
1832+
{
18131833
let no_symbols = ExplicitSymbolTable::default();
18141834
let local_scope: &ExplicitSymbolTable = self.local_symbols.as_ref().unwrap_or(&no_symbols);
18151835
let mut result: Vec<Result<_, _>> = Vec::new();
@@ -1859,7 +1879,9 @@ impl InstructionSequence {
18591879
}
18601880

18611881
if self.local_symbols.is_some() {
1862-
panic!("InstructionSequence::build_binary_block: evaluation with local symbol tables is not yet implemented");
1882+
panic!(
1883+
"InstructionSequence::build_binary_block: evaluation with local symbol tables is not yet implemented"
1884+
);
18631885
}
18641886
let mut ctx = EvaluationContext {
18651887
explicit_symtab,
@@ -1903,7 +1925,8 @@ pub(crate) struct Equality {
19031925
impl Equality {
19041926
pub(super) fn symbol_uses(
19051927
&self,
1906-
) -> impl Iterator<Item = Result<(SymbolName, Span, SymbolUse), InconsistentSymbolUse>> + use<> {
1928+
) -> impl Iterator<Item = Result<(SymbolName, Span, SymbolUse), InconsistentSymbolUse>> + use<>
1929+
{
19071930
[Ok((
19081931
self.name.clone(),
19091932
self.span,

assembler/src/asmlib/collections.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,13 @@ impl<T> OneOrMore<T> {
7171
}
7272

7373
pub fn try_from_iter<I: Iterator<Item = T>>(mut it: I) -> Result<Self, NoItems> {
74-
match it.next() { Some(head) => {
75-
Ok(Self {
74+
match it.next() {
75+
Some(head) => Ok(Self {
7676
head,
7777
tail: it.collect(),
78-
})
79-
} _ => {
80-
Err(NoItems {})
81-
}}
78+
}),
79+
_ => Err(NoItems {}),
80+
}
8281
}
8382

8483
pub fn extend<I: Iterator<Item = T>>(&mut self, items: I) {

assembler/src/asmlib/driver.rs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ use std::io::{BufReader, BufWriter, Read};
1010
use std::path::{Path, PathBuf};
1111

1212
use chumsky::error::Rich;
13-
use tracing::{event, span, Level};
13+
use tracing::{Level, event, span};
1414

1515
use super::ast::*;
1616
use super::collections::OneOrMore;
1717
use super::directive::Directive;
1818
use super::eval::Evaluate;
1919
use super::eval::HereValue;
20-
use super::eval::{extract_final_equalities, EvaluationContext, RcBlock};
20+
use super::eval::{EvaluationContext, RcBlock, extract_final_equalities};
2121
use super::lexer;
2222
use super::listing::*;
2323
#[cfg(test)]
@@ -35,8 +35,8 @@ use super::span::*;
3535
use super::state::{NumeralMode, State};
3636
use super::symbol::SymbolName;
3737
use super::symtab::{
38-
assign_default_rc_word_tags, ExplicitSymbolTable, FinalSymbolDefinition, FinalSymbolTable,
39-
FinalSymbolType, ImplicitSymbolTable, IndexRegisterAssigner,
38+
ExplicitSymbolTable, FinalSymbolDefinition, FinalSymbolTable, FinalSymbolType,
39+
ImplicitSymbolTable, IndexRegisterAssigner, assign_default_rc_word_tags,
4040
};
4141
use super::types::*;
4242
use base::prelude::{Address, IndexBy, Unsigned18Bit, Unsigned36Bit};
@@ -117,7 +117,9 @@ fn assemble_nonempty_input<'a, 'b: 'a>(input: &'b Source<'a>) -> AssemblerPass1O
117117
Ok((None, _output_options)) => match OneOrMore::try_from_vec(errors) {
118118
Ok(errors) => AssemblerPass1Or2Output::Pass1Failed(Ok(errors)),
119119
Err(_) => {
120-
unreachable!("assemble_pass1 returned no SourceFile instance but there were no output errors either");
120+
unreachable!(
121+
"assemble_pass1 returned no SourceFile instance but there were no output errors either"
122+
);
121123
}
122124
},
123125
Ok((Some(source_file), output_options)) => match assemble_pass2(source_file, input) {
@@ -364,9 +366,9 @@ fn assemble_pass2<'s>(
364366
match (&block_identifier, &block_position).evaluate(&mut ctx) {
365367
Ok(value) => {
366368
if !ctx.index_register_assigner.is_empty() {
367-
return Err(AssemblerFailure::InternalError(
368-
format!(
369-
"While determining the addresses of {block_identifier}, we assigned an index register. Block origins should not depend on index registers")));
369+
return Err(AssemblerFailure::InternalError(format!(
370+
"While determining the addresses of {block_identifier}, we assigned an index register. Block origins should not depend on index registers"
371+
)));
370372
}
371373

372374
let address: Address = subword::right_half(value).into();
@@ -541,11 +543,15 @@ fn assemble_pass3(
541543
for name in implicit_symtab.symbols() {
542544
match (implicit_symtab.get(name), explicit_symtab.get(name)) {
543545
(Some(implicit), Some(explicit)) => {
544-
panic!("symbol {name} appears in both the implicit ({implicit:#?} and the explicit ({explicit:#?} symbol tables");
546+
panic!(
547+
"symbol {name} appears in both the implicit ({implicit:#?} and the explicit ({explicit:#?} symbol tables"
548+
);
545549
}
546550
(Some(_), None) | (None, Some(_)) => (),
547551
(None, None) => {
548-
panic!("symbol {name} is returned by ImplicitSymbolTable::symbols() but is not defined there");
552+
panic!(
553+
"symbol {name} is returned by ImplicitSymbolTable::symbols() but is not defined there"
554+
);
549555
}
550556
}
551557
}
@@ -866,8 +872,11 @@ fn test_duplicate_global_tag() {
866872
inner: ProgramError::SyntaxError { msg, span: _ },
867873
..
868874
} => {
869-
assert!(msg
870-
.contains("bad symbol definition for TGX: TGX is defined more than once"));
875+
assert!(
876+
msg.contains(
877+
"bad symbol definition for TGX: TGX is defined more than once"
878+
)
879+
);
871880
}
872881
other => {
873882
panic!("expected a syntax error report, got {other:?}");

assembler/src/asmlib/driver/output.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use std::io::Write;
22
use std::path::Path;
33

4-
use tracing::{event, span, Level};
4+
use tracing::{Level, event, span};
55

66
use base::prelude::{
7-
join_halves, split_halves, u18, u5, u6, unsplay, Address, Instruction, Opcode, OperandAddress,
8-
Signed18Bit, SymbolicInstruction, Unsigned18Bit, Unsigned36Bit, Unsigned6Bit,
7+
Address, Instruction, Opcode, OperandAddress, Signed18Bit, SymbolicInstruction, Unsigned6Bit,
8+
Unsigned18Bit, Unsigned36Bit, join_halves, split_halves, u5, u6, u18, unsplay,
99
};
1010

1111
use super::super::readerleader::reader_leader;
@@ -146,7 +146,9 @@ fn create_begin_block(
146146
// should closely examine what appear to be the original
147147
// (TX-2 assembly language) programmer's assumptions about
148148
// what will happen.
149-
panic!("PUNCH directive specifies deferred start address {start:o}; this is (deliberately) not yet supported - check carefully!");
149+
panic!(
150+
"PUNCH directive specifies deferred start address {start:o}; this is (deliberately) not yet supported - check carefully!"
151+
);
150152
}
151153
// When there is a known start address `start` we emit a `JPQ
152154
// start` instruction into memory register 0o27.
@@ -193,8 +195,10 @@ pub fn write_user_program<W: Write>(
193195
write_data(writer, output_file_name, &reader_leader())?;
194196
for chunk in binary.chunks().iter() {
195197
if chunk.is_empty() {
196-
event!(Level::ERROR, "Will not write empty block at {:o}; the assembler should not have generated one; this is a bug.",
197-
chunk.address,
198+
event!(
199+
Level::ERROR,
200+
"Will not write empty block at {:o}; the assembler should not have generated one; this is a bug.",
201+
chunk.address,
198202
);
199203
continue;
200204
}

0 commit comments

Comments
 (0)