Skip to content

Commit ad08ccd

Browse files
committed
[assembler] Fix some new clippy warnings (following rustup update).
1 parent e75050a commit ad08ccd

File tree

8 files changed

+21
-27
lines changed

8 files changed

+21
-27
lines changed

assembler/src/asmlib/parser/helpers.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,13 @@ pub(super) fn punch_address(a: Option<LiteralValue>) -> Result<PunchCommand, Str
7676
let value = literal.value();
7777
match Unsigned18Bit::try_from(value) {
7878
Err(e) => Err(format!(
79-
"PUNCH address value {:o} is not a valid address: {}",
80-
value, e
79+
"PUNCH address value {value:o} is not a valid address: {e}",
8180
)),
8281
Ok(halfword) => {
8382
let addr: Address = Address::from(halfword);
8483
if addr.mark_bit() != Unsigned18Bit::ZERO {
8584
Err(format!(
86-
"PUNCH address value {:o} must not be a deferred address",
87-
addr
85+
"PUNCH address value {addr:o} must not be a deferred address",
8886
))
8987
} else {
9088
Ok(PunchCommand(Some(addr)))

assembler/src/asmlib/readerleader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ fn bit_index(q: u8, bitnum: u8) -> Unsigned6Bit {
1010
1..=3 => q,
1111
4 => 0,
1212
_ => {
13-
panic!("invalid quarter number {}", q);
13+
panic!("invalid quarter number {q}");
1414
}
1515
};
1616
if bitnum > 12 {
17-
panic!("invalid bit number {}", bitnum);
17+
panic!("invalid bit number {bitnum}");
1818
}
1919
Unsigned6Bit::try_from((quarter << 4) | bitnum).unwrap()
2020
}

assembler/src/asmlib/symbol.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ impl Display for InconsistentSymbolUse {
116116
_origin_2,
117117
block_identifier_2,
118118
) => {
119-
write!(f, "symbol {} cannot simultaneously be the origin for {} and {}; names must be unique",
120-
name, block_identifier_1, block_identifier_2)
119+
write!(f, "symbol {name} cannot simultaneously be the origin for {block_identifier_1} and {block_identifier_2}; names must be unique")
121120
}
122121
InconsistentSymbolUse::MixingOrigin(name, _origin, _incompatibility) => {
123122
write!(f, "symbols (in this case {name}) cannot be used as an origin name and a configuration or index value")

assembler/src/asmlib/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl Display for ProgramError {
152152
Ok(())
153153
}
154154
SyntaxError { span: _, msg } => {
155-
write!(f, "{}", msg)
155+
write!(f, "{msg}")
156156
}
157157
}
158158
}

assembler/src/tx2dis/main.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ fn disassemble_block(mut pos: Unsigned18Bit, block: &[Unsigned36Bit]) {
9999

100100
fn disassemble_word(loc: Unsigned18Bit, w: Unsigned36Bit, is_origin: bool) {
101101
if is_origin {
102-
print!("{:>06o}|", loc);
102+
print!("{loc:>06o}|");
103103
} else {
104104
print!("{:7}", "");
105105
}
@@ -113,7 +113,7 @@ fn disassemble_word(loc: Unsigned18Bit, w: Unsigned36Bit, is_origin: bool) {
113113
}
114114
}
115115
let (left, right) = split_halves(w);
116-
println!("|{:>06o} {:>06o}|{:>6o}", left, right, loc);
116+
println!("|{left:>06o} {right:>06o}|{loc:>6o}");
117117
}
118118

119119
fn disassemble_chunk<R: Read>(input: &mut R, checksum: &mut Signed18Bit) -> Result<bool, Fail> {
@@ -134,7 +134,7 @@ fn disassemble_chunk<R: Read>(input: &mut R, checksum: &mut Signed18Bit) -> Resu
134134
None => None,
135135
}
136136
.expect("overflow in block length");
137-
println!("** {}-word chunk ending at {}", len, end);
137+
println!("** {len}-word chunk ending at {end}");
138138
let u_origin = end
139139
.checked_sub(len)
140140
.and_then(|n| n.checked_add(Unsigned18Bit::ONE))
@@ -155,11 +155,10 @@ fn disassemble_chunk<R: Read>(input: &mut R, checksum: &mut Signed18Bit) -> Resu
155155
{
156156
let unsigned_checksum = checksum.reinterpret_as_unsigned();
157157
if unsigned_checksum.is_zero() {
158-
println!("** Checksum is valid: {:>06o}", unsigned_checksum);
158+
println!("** Checksum is valid: {unsigned_checksum:>06o}");
159159
} else {
160160
println!(
161-
"** Checksum is not valid: {:>06o}, this tape cannot be loaded as-is",
162-
unsigned_checksum
161+
"** Checksum is not valid: {unsigned_checksum:>06o}, this tape cannot be loaded as-is",
163162
);
164163
}
165164
}
@@ -169,7 +168,7 @@ fn disassemble_chunk<R: Read>(input: &mut R, checksum: &mut Signed18Bit) -> Resu
169168
println!("** This is the final block");
170169
Ok(false)
171170
} else {
172-
eprintln!("warning: block has unexpected next-address {:o}", next);
171+
eprintln!("warning: block has unexpected next-address {next:o}");
173172
Ok(false)
174173
}
175174
}
@@ -181,8 +180,7 @@ fn check_header<R: Read>(input: &mut R) -> Result<(), Fail> {
181180
if want != got {
182181
return Err(Fail::Generic(
183182
format!(
184-
"File does not begin with the expected header; at position {} we expected {:>012o} but got {:>012o}",
185-
pos, want, got)));
183+
"File does not begin with the expected header; at position {pos} we expected {want:>012o} but got {got:>012o}")));
186184
}
187185
}
188186
println!("** reader leader is valid:");
@@ -195,7 +193,7 @@ fn disassemble_file(input_file_name: &OsStr) -> Result<(), Fail> {
195193
let input_file = OpenOptions::new()
196194
.read(true)
197195
.open(input_file_name)
198-
.map_err(|e| Fail::Generic(format!("failed to open input file: {}", e)))?;
196+
.map_err(|e| Fail::Generic(format!("failed to open input file: {e}")))?;
199197
let mut reader = BufReader::new(input_file);
200198
check_header(&mut reader)?;
201199
let mut checksum: Signed18Bit = Signed18Bit::ZERO;
@@ -249,7 +247,7 @@ fn disassemble() -> Result<(), Fail> {
249247
{
250248
Err(e) => {
251249
return Err(Fail::Generic(
252-
format!("failed to initialise tracing filter (perhaps there is a problem with environment variables): {}", e)));
250+
format!("failed to initialise tracing filter (perhaps there is a problem with environment variables): {e}")));
253251
}
254252
Ok(layer) => layer,
255253
};
@@ -267,7 +265,7 @@ fn disassemble() -> Result<(), Fail> {
267265
fn main() {
268266
match disassemble() {
269267
Err(e) => {
270-
eprintln!("error: {}", e);
268+
eprintln!("error: {e}");
271269
std::process::exit(1);
272270
}
273271
Ok(()) => {

assembler/src/tx2m4as/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fn run_asembler() -> Result<(), Fail> {
4444
{
4545
Err(e) => {
4646
return Err(Fail::InitialisationFailure(
47-
format!("failed to initialise tracing filter (perhaps there is a problem with environment variables): {}", e)));
47+
format!("failed to initialise tracing filter (perhaps there is a problem with environment variables): {e}")));
4848
}
4949
Ok(layer) => layer,
5050
};
@@ -72,7 +72,7 @@ fn main() {
7272

7373
match run_asembler() {
7474
Err(e) => {
75-
eprintln!("{}", e);
75+
eprintln!("{e}");
7676
std::process::exit(1);
7777
}
7878
Ok(()) => {

assembler/src/tx2maketape/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ fn run_utility() -> Result<(), Fail> {
171171
let input_file = OpenOptions::new()
172172
.read(true)
173173
.open(cli.input)
174-
.map_err(|e| Fail(format!("failed to open input file: {}", e)))?;
174+
.map_err(|e| Fail(format!("failed to open input file: {e}")))?;
175175
let binary = read_binary(input_file)?;
176176

177177
let output_path = PathBuf::from(cli.output);
@@ -192,7 +192,7 @@ fn run_utility() -> Result<(), Fail> {
192192
fn main() {
193193
match run_utility() {
194194
Err(e) => {
195-
eprintln!("{}", e);
195+
eprintln!("{e}");
196196
std::process::exit(1);
197197
}
198198
Ok(()) => {

assembler/tests/hello-golden.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ fn files_are_identical(expected: &OsStr, got: &OsStr) -> Result<(), String> {
3939
let got_file_len = got_file.metadata().expect(COMPLAIN).len();
4040
if expected_file_len != got_file_len {
4141
return Err(format!(
42-
"wrong file length: {:?} is {} bytes but {:?} is {} bytes",
43-
expected, expected_file_len, got, got_file_len
42+
"wrong file length: {expected:?} is {expected_file_len} bytes but {got:?} is {got_file_len} bytes",
4443
));
4544
}
4645

0 commit comments

Comments
 (0)