Skip to content

Commit 4532c0f

Browse files
committed
[assembler] Fix some clippy warnings.
1 parent aae5a10 commit 4532c0f

File tree

4 files changed

+16
-30
lines changed

4 files changed

+16
-30
lines changed

assembler/src/asmlib/lexer/tests.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ fn is_error_token(t: &Token) -> bool {
55
matches!(t, Token::Error(_))
66
}
77

8-
fn scan_slices<'a>(input: &'a str) -> Result<Vec<(Token, &'a str)>, Unrecognised> {
8+
fn scan_slices(input: &str) -> Result<Vec<(Token, &str)>, Unrecognised> {
99
dbg!(input);
1010
dbg!(input.len());
1111

@@ -20,7 +20,7 @@ fn scan_slices<'a>(input: &'a str) -> Result<Vec<(Token, &'a str)>, Unrecognised
2020
Lexer::new(input).spanned().map(mapping).collect()
2121
}
2222

23-
fn scan_tokens_only<'a>(input: &'a str) -> Result<Vec<Token>, Unrecognised> {
23+
fn scan_tokens_only(input: &str) -> Result<Vec<Token>, Unrecognised> {
2424
Lexer::new(input).collect()
2525
}
2626

@@ -1520,11 +1520,8 @@ fn test_superscript_symex_long() {
15201520
fn test_superscript_symex_bad() {
15211521
let result = scan_tokens_only("@sup_sps@");
15221522
dbg!(&result);
1523-
match result {
1524-
Ok(tokens) => {
1525-
assert!(tokens.iter().any(is_error_token));
1526-
}
1527-
Err(_) => (),
1523+
if let Ok(tokens) = result {
1524+
assert!(tokens.iter().any(is_error_token));
15281525
}
15291526
}
15301527

@@ -1680,11 +1677,8 @@ fn test_subscript_symex_long() {
16801677
fn test_subscript_symex_bad() {
16811678
let result = scan_tokens_only("@sub_sps@");
16821679
dbg!(&result);
1683-
match result {
1684-
Ok(tokens) => {
1685-
assert!(tokens.iter().any(is_error_token));
1686-
}
1687-
Err(_) => (),
1680+
if let Ok(tokens) = result {
1681+
assert!(tokens.iter().any(is_error_token));
16881682
}
16891683
}
16901684

assembler/src/asmlib/parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,15 +546,15 @@ where
546546
state: &State,
547547
span: Span,
548548
) -> Result<MacroDefinition, chumsky::error::Rich<'a, lexer::Token>> {
549-
match state.get_macro_definition(&name) {
549+
match state.get_macro_definition(name) {
550550
None => Err(Rich::custom(span, format!("unknown macro {name}"))),
551551
Some(macro_def) => Ok(macro_def.clone()),
552552
}
553553
}
554554

555555
symex::parse_symex(SymexSyllableRule::OneOnly, Script::Normal).try_map_with(|name, extra| {
556556
let span: Span = extra.span();
557-
let state: &State = &extra.state();
557+
let state: &State = extra.state();
558558
mapping(&name, state, span)
559559
})
560560
}
@@ -593,7 +593,7 @@ where
593593
}
594594

595595
#[cfg(test)] // not yet used outside tests.
596-
impl<'src, 'b, I> ExtParser<'src, I, MacroInvocation, ExtraWithoutContext<'src>>
596+
impl<'src, I> ExtParser<'src, I, MacroInvocation, ExtraWithoutContext<'src>>
597597
for MacroInvocationParser<'src, I>
598598
where
599599
I: Input<'src, Token = Tok, Span = Span> + ValueInput<'src>,

assembler/src/asmlib/parser/tests.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,7 @@ fn parse_multiple_instruction_fragments(input: &str) -> Vec<InstructionFragment>
264264
parse_result
265265
.fragments
266266
.into_iter()
267-
.map(|comma_delimited_insn| match comma_delimited_insn {
268-
CommaDelimitedFragment {
269-
span: _,
270-
leading_commas: _,
271-
holdbit: _,
272-
fragment: inst,
273-
trailing_commas: _,
274-
} => inst,
275-
})
267+
.map(|comma_delimited_insn| comma_delimited_insn.fragment)
276268
.collect()
277269
}
278270

@@ -1043,7 +1035,7 @@ fn test_assignment_literal() {
10431035
dbg!(&input);
10441036
dbg!(&begin);
10451037
assert_eq!(
1046-
parse_successfully_with(*input, assignment.clone(), no_state_setup),
1038+
parse_successfully_with(input, assignment.clone(), no_state_setup),
10471039
assignment_of_literal(
10481040
"FOO",
10491041
span(0..(*begin + 1)),
@@ -1066,7 +1058,7 @@ fn test_assignment_superscript() {
10661058
let val_span = span(*val_begin..*val_end);
10671059
let assignment = grammar().assignment;
10681060
assert_eq!(
1069-
parse_successfully_with(*input, assignment, no_state_setup),
1061+
parse_successfully_with(input, assignment, no_state_setup),
10701062
Equality {
10711063
span: span(0..*val_end),
10721064
name: SymbolName::from("FOO"),
@@ -1108,7 +1100,7 @@ fn test_assignment_subscript() {
11081100
dbg!(&val_begin);
11091101
dbg!(&val_end);
11101102
assert_eq!(
1111-
parse_successfully_with(*input, assignment.clone(), no_state_setup),
1103+
parse_successfully_with(input, assignment.clone(), no_state_setup),
11121104
assignment_of_literal(
11131105
"FOO",
11141106
span(0..*val_end),
@@ -2106,7 +2098,7 @@ mod comma_tests {
21062098

21072099
impl PartialEq<CommaDelimitedFragment> for Briefly {
21082100
fn eq(&self, other: &CommaDelimitedFragment) -> bool {
2109-
self == other
2101+
&self.0 == other
21102102
}
21112103
}
21122104

@@ -2552,7 +2544,7 @@ fn test_make_bit_designator_literal() {
25522544
if (n & (!MASK)) != 0 {
25532545
panic!("bit designator {what} produced output {n:o} but that has bits set outside the allowed mask {MASK:o}");
25542546
}
2555-
if let Some((prevq, prevb)) = seen.insert(n.clone(), (q, bit)) {
2547+
if let Some((prevq, prevb)) = seen.insert(n, (q, bit)) {
25562548
panic!(
25572549
"two distinct bit designators both evaluate to {n}: {what} and {}",
25582550
makename(prevq, prevb)

assembler/src/asmlib/readerleader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ fn test_reader_leader() {
461461

462462
assert_eq!(expected.len(), 0o24);
463463
assert_eq!(leader.len(), expected.len());
464-
for (i, expected_value) in expected.iter().copied().map(u64::from).enumerate() {
464+
for (i, expected_value) in expected.iter().copied().enumerate() {
465465
assert_eq!(
466466
leader[i],
467467
expected_value,

0 commit comments

Comments
 (0)