Skip to content

Commit cc977c8

Browse files
committed
[assembler] Clippy: enable, fix manual_assert.
1 parent fa61af3 commit cc977c8

File tree

7 files changed

+25
-32
lines changed

7 files changed

+25
-32
lines changed

assembler/src/asmlib/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1870,7 +1870,7 @@ impl InstructionSequence {
18701870
}
18711871

18721872
if self.local_symbols.is_some() {
1873-
panic!(
1873+
unimplemented!(
18741874
"InstructionSequence::build_binary_block: evaluation with local symbol tables is not yet implemented"
18751875
);
18761876
}

assembler/src/asmlib/driver/output.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ 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!(
149+
unimplemented!(
150150
"PUNCH directive specifies deferred start address {start:o}; this is (deliberately) not yet supported - check carefully!"
151151
);
152152
}

assembler/src/asmlib/driver/tests.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,10 @@ fn assemble_check_symbols(
5454
let scope = ScopeIdentifier::global();
5555
match evaluate_symbol(&sym, Script::Normal, span, &mut ctx, scope) {
5656
Ok(got) => {
57-
if got != *expected_value {
58-
panic!(
59-
"incorrect value for symbol {name}; expected {expected_value:?}, got {got:?}"
60-
);
61-
}
57+
assert_eq!(
58+
got, *expected_value,
59+
"incorrect value for symbol {name}; expected {expected_value:?}, got {got:?}"
60+
);
6261
}
6362
Err(e) => {
6463
panic!("unexpected error looking up value for symbol {name}: {e:?}");

assembler/src/asmlib/eval.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -506,12 +506,11 @@ impl RcAllocator for RcBlock {
506506

507507
impl RcUpdater for RcBlock {
508508
fn update(&mut self, address: Address, value: Unsigned36Bit) {
509-
if address < self.address {
510-
panic!(
511-
"out of range access to address {address} of RC-block starting at {}",
512-
self.address
513-
);
514-
}
509+
assert!(
510+
address >= self.address,
511+
"out of range access to address {address} of RC-block starting at {}",
512+
self.address
513+
);
515514
match Unsigned18Bit::from(address).checked_sub(Unsigned18Bit::from(self.address)) {
516515
Some(offset) => match self.words.get_mut(usize::from(offset)) {
517516
Some((_source, spot)) => {

assembler/src/asmlib/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#![allow(clippy::default_trait_access)] // fix later
2222
#![allow(clippy::match_wild_err_arm)] // fix later
2323
#![allow(clippy::verbose_bit_mask)] // fix later
24-
#![allow(clippy::manual_assert)] // fix soon
2524
#![allow(clippy::if_not_else)] // fix soon
2625
#![allow(clippy::doc_markdown)] // fix soon
2726
#![allow(clippy::needless_pass_by_value)] // fix soon

assembler/src/asmlib/parser/tests.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,11 +1453,10 @@ fn test_subs() {
14531453
parse_multi_syllable_symex(SymexSyllableRule::Multiple, Script::Normal),
14541454
no_state_setup,
14551455
);
1456-
if got != expected {
1457-
panic!(
1458-
"Parsing '{input}' with parse_multi_syllable_symex, expected '{expected}', got '{got}'"
1459-
);
1460-
}
1456+
assert_eq!(
1457+
got, expected,
1458+
"Parsing '{input}' with parse_multi_syllable_symex, expected '{expected}', got '{got}'"
1459+
);
14611460
}
14621461

14631462
check("@beta@", "β");
@@ -1485,11 +1484,10 @@ fn test_greek_letters() {
14851484
parse_multi_syllable_symex(SymexSyllableRule::Multiple, Script::Normal),
14861485
no_state_setup,
14871486
);
1488-
if got != input {
1489-
panic!(
1490-
"Parsing '{input}' with parse_multi_syllable_symex, expected '{input}', got '{got}'"
1491-
);
1492-
}
1487+
assert_eq!(
1488+
got, input,
1489+
"Parsing '{input}' with parse_multi_syllable_symex, expected '{input}', got '{got}'"
1490+
);
14931491
}
14941492
check("β");
14951493
check("γ");
@@ -2699,11 +2697,11 @@ fn test_make_bit_designator_literal() {
26992697
BitDesignatorValidation::Good(literal) => {
27002698
dbg!(&literal);
27012699
let n = literal.unshifted_value();
2702-
if (n & (!MASK)) != 0 {
2703-
panic!(
2704-
"bit designator {what} produced output {n:o} but that has bits set outside the allowed mask {MASK:o}"
2705-
);
2706-
}
2700+
assert_eq!(
2701+
(n & (!MASK)),
2702+
0,
2703+
"bit designator {what} produced output {n:o} but that has bits set outside the allowed mask {MASK:o}"
2704+
);
27072705
if let Some((prevq, prevb)) = seen.insert(n, (q, bit)) {
27082706
panic!(
27092707
"two distinct bit designators both evaluate to {n}: {what} and {}",

assembler/src/asmlib/readerleader.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ fn bit_index(q: u8, bitnum: u8) -> Unsigned6Bit {
1414
panic!("invalid quarter number {q}");
1515
}
1616
};
17-
if bitnum > 12 {
18-
panic!("invalid bit number {bitnum}");
19-
}
17+
assert!(bitnum <= 12, "invalid bit number {bitnum}");
2018
Unsigned6Bit::try_from((quarter << 4) | bitnum).unwrap()
2119
}
2220

0 commit comments

Comments
 (0)