Skip to content

Commit 6c13267

Browse files
committed
[assembler] Clippy: enable, fix redundant_closure_for_method_calls.
1 parent cb79cf0 commit 6c13267

File tree

9 files changed

+17
-16
lines changed

9 files changed

+17
-16
lines changed

assembler/src/asmlib/ast.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ impl RegistersContaining {
549549
let tmp_rc: OneOrMore<Option<RegisterContaining>> = self
550550
.0
551551
.map(|rc| rc.substitute_macro_parameters(param_values, on_missing, macros));
552-
if tmp_rc.iter().all(|maybe_rc| maybe_rc.is_some()) {
552+
if tmp_rc.iter().all(Option::is_some) {
553553
Some(RegistersContaining(tmp_rc.into_map(|maybe_rc| {
554554
maybe_rc.expect("we already checked this wasn't None")
555555
})))
@@ -1389,9 +1389,9 @@ impl CommaDelimitedFragment {
13891389
) -> Self {
13901390
let span: Span = {
13911391
let spans: [Option<Span>; 3] = [
1392-
leading_commas.as_ref().map(|c| c.span()),
1392+
leading_commas.as_ref().map(Spanned::span),
13931393
Some(instruction.span),
1394-
trailing_commas.as_ref().map(|c| c.span()),
1394+
trailing_commas.as_ref().map(Spanned::span),
13951395
];
13961396
match spans {
13971397
[_, None, _] => {
@@ -1496,7 +1496,7 @@ impl UntaggedProgramInstruction {
14961496
let tmp_frags: OneOrMore<Option<CommaDelimitedFragment>> = self
14971497
.fragments
14981498
.map(|frag| frag.substitute_macro_parameters(param_values, on_missing, macros));
1499-
if tmp_frags.iter().any(|frag| frag.is_none()) {
1499+
if tmp_frags.iter().any(Option::is_none) {
15001500
None
15011501
} else {
15021502
Some(UntaggedProgramInstruction {
@@ -1830,7 +1830,9 @@ impl InstructionSequence {
18301830
}
18311831

18321832
pub(crate) fn emitted_word_count(&self) -> Unsigned18Bit {
1833-
self.iter().map(|st| st.emitted_word_count()).sum()
1833+
self.iter()
1834+
.map(TaggedProgramInstruction::emitted_word_count)
1835+
.sum()
18341836
}
18351837

18361838
#[allow(clippy::too_many_arguments)]

assembler/src/asmlib/directive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl Directive {
6767
pub(super) fn position_rc_block(&mut self) -> Address {
6868
self.blocks
6969
.values()
70-
.map(|block| block.following_addr())
70+
.map(LocatedBlock::following_addr)
7171
.max()
7272
.unwrap_or_else(Origin::default_address)
7373
}

assembler/src/asmlib/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ pub struct Binary {
239239

240240
impl Binary {
241241
fn count_words(&self) -> usize {
242-
self.chunks().iter().map(|chunk| chunk.count_words()).sum()
242+
self.chunks().iter().map(BinaryChunk::count_words).sum()
243243
}
244244

245245
fn entry_point(&self) -> Option<Address> {

assembler/src/asmlib/eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl Display for EvaluationFailure {
8585
deps_in_order,
8686
span: _,
8787
} => {
88-
let names: Vec<String> = deps_in_order.iter().map(|dep| dep.to_string()).collect();
88+
let names: Vec<String> = deps_in_order.iter().map(ToString::to_string).collect();
8989
write!(
9090
f,
9191
"definition of {} has a dependency loop ({})",

assembler/src/asmlib/lib.rs

Lines changed: 1 addition & 2 deletions
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::redundant_closure_for_method_calls)] // fix later
2524
#![allow(clippy::manual_assert)] // fix soon
2625
#![allow(clippy::if_not_else)] // fix soon
2726
#![allow(clippy::doc_markdown)] // fix soon
@@ -32,7 +31,7 @@
3231
#![allow(clippy::match_wildcard_for_single_variants)] // fix soon
3332
#![allow(clippy::trivially_copy_pass_by_ref)] // fix soon
3433
#![allow(clippy::unnecessary_wraps)] // fix soon
35-
#![warn(clippy::inconsistent_struct_constructor)] // fix soon
34+
#![warn(clippy::redundant_closure_for_method_calls)]
3635

3736
mod ast;
3837
mod collections;

assembler/src/asmlib/manuscript.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl SourceFile {
9494
let uses_in_global_assignments = self
9595
.global_equalities
9696
.iter()
97-
.flat_map(|eq| eq.symbol_uses());
97+
.flat_map(Equality::symbol_uses);
9898
uses_in_instructions.chain(uses_in_global_assignments)
9999
}
100100

@@ -410,7 +410,7 @@ impl ManuscriptBlock {
410410
pub(crate) fn instruction_count(&self) -> Unsigned18Bit {
411411
self.sequences
412412
.iter()
413-
.map(|seq| seq.emitted_word_count())
413+
.map(InstructionSequence::emitted_word_count)
414414
.sum()
415415
}
416416

assembler/src/asmlib/memorymap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl LocatedBlock {
168168
pub(super) fn emitted_word_count(&self) -> Unsigned18Bit {
169169
self.sequences
170170
.iter()
171-
.map(|seq| seq.emitted_word_count())
171+
.map(InstructionSequence::emitted_word_count)
172172
.sum()
173173
}
174174

assembler/src/asmlib/parser/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ fn test_parse_multi_syllable_symex() {
476476
parse_successfully_with(input, zero_or_more_symexes.clone(), no_state_setup);
477477
let got_canonicals: Vec<String> =
478478
got.into_iter().map(|symbol| symbol.to_string()).collect();
479-
let expected_canonicals: Vec<String> = expected.iter().map(|s| s.to_string()).collect();
479+
let expected_canonicals: Vec<String> = expected.iter().map(ToString::to_string).collect();
480480
assert_eq!(got_canonicals, expected_canonicals);
481481
}
482482
}
@@ -499,7 +499,7 @@ fn test_parse_single_syllable_symex() {
499499
parse_successfully_with(input, zero_or_more_symexes.clone(), no_state_setup);
500500
let got_canonicals: Vec<String> =
501501
got.into_iter().map(|symbol| symbol.to_string()).collect();
502-
let expected_canonicals: Vec<String> = expected.iter().map(|s| s.to_string()).collect();
502+
let expected_canonicals: Vec<String> = expected.iter().map(ToString::to_string).collect();
503503
assert_eq!(got_canonicals, expected_canonicals);
504504
}
505505
}

assembler/src/asmlib/source.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<'s> Source<'s> {
4949
Some(n) => n + 1,
5050
};
5151
let prefix = &self.body[line_start..pos];
52-
if prefix.chars().all(|ch| ch.is_whitespace()) {
52+
if prefix.chars().all(char::is_whitespace) {
5353
prefix
5454
} else {
5555
""

0 commit comments

Comments
 (0)