Skip to content

Commit 185c3d5

Browse files
committed
[cpu] Fix some new clippy warnings (following rustup update).
1 parent 7c97fd4 commit 185c3d5

File tree

11 files changed

+45
-60
lines changed

11 files changed

+45
-60
lines changed

cpu/src/alarm.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ pub enum BadMemOp {
1616
impl Display for BadMemOp {
1717
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
1818
match self {
19-
BadMemOp::Read(addr) => write!(f, "memory read from {:>013o} failed", addr),
20-
BadMemOp::Write(addr) => write!(f, "memory write to {:>013o} failed", addr),
19+
BadMemOp::Read(addr) => write!(f, "memory read from {addr:>013o} failed"),
20+
BadMemOp::Write(addr) => write!(f, "memory write to {addr:>013o} failed"),
2121
}
2222
}
2323
}
@@ -252,15 +252,13 @@ impl Display for AlarmDetails {
252252
QSAL(instruction, op, msg) => {
253253
write!(
254254
f,
255-
"QSAL: during execution of instruction {:?}, {}: {}",
256-
instruction, op, msg,
255+
"QSAL: during execution of instruction {instruction:?}, {op}: {msg}",
257256
)
258257
}
259258
PSAL(address, msg) => {
260259
write!(
261260
f,
262-
"PSAL: P register set to illegal address {:>06o}: {}",
263-
address, msg
261+
"PSAL: P register set to illegal address {address:>06o}: {msg}",
264262
)
265263
}
266264
OCSAL(inst, msg) => {
@@ -274,8 +272,7 @@ impl Display for AlarmDetails {
274272
ROUNDTUITAL(msg) => {
275273
write!(
276274
f,
277-
"ROUNDTUITAL: the program used a feature not supported in the emulator: {}",
278-
msg
275+
"ROUNDTUITAL: the program used a feature not supported in the emulator: {msg}",
279276
)
280277
}
281278

@@ -284,11 +281,11 @@ impl Display for AlarmDetails {
284281
operand,
285282
message,
286283
} => {
287-
write!(f, "IOSAL: I/O alarm during operation on unit {:o}", unit,)?;
284+
write!(f, "IOSAL: I/O alarm during operation on unit {unit:o}")?;
288285
if let Some(oper) = operand {
289-
write!(f, " with operand {}", oper)?;
286+
write!(f, " with operand {oper}")?;
290287
}
291-
write!(f, ": {}", message)
288+
write!(f, ": {message}")
292289
}
293290

294291
MISAL { affected_unit } => write!(
@@ -317,8 +314,7 @@ impl Display for AlarmDetails {
317314
DEFERLOOPAL { address } => {
318315
write!(
319316
f,
320-
"DEFERLOOPAL: infinite loop in deferred address at {:>012o}",
321-
address,
317+
"DEFERLOOPAL: infinite loop in deferred address at {address:>012o}",
322318
)
323319
}
324320
}
@@ -338,7 +334,7 @@ impl Display for UnmaskedAlarm {
338334
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
339335
write!(f, "unmasked alarm {}", self.alarm)?;
340336
if let Some(address) = self.address {
341-
write!(f, "at address {}", address)
337+
write!(f, "at address {address}")
342338
} else {
343339
Ok(())
344340
}

cpu/src/control.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ impl ResetMode {
429429
Some(physical_address)
430430
}
431431
Err(e) => {
432-
panic!("failed to fetch reset {:?}: {}", self, e);
432+
panic!("failed to fetch reset {self:?}: {e}");
433433
}
434434
}
435435
}
@@ -1117,16 +1117,15 @@ impl ControlUnit {
11171117
_ => Err(Alarm {
11181118
sequence: control.regs.k,
11191119
details: AlarmDetails::ROUNDTUITAL(format!(
1120-
"The emulator does not yet implement opcode {}",
1121-
opcode,
1120+
"The emulator does not yet implement opcode {opcode}",
11221121
)),
11231122
}),
11241123
}
11251124
}
11261125

11271126
let seq_desc = match self.regs.k {
11281127
None => "none".to_string(),
1129-
Some(n) => format!("{:02o}", n),
1128+
Some(n) => format!("{n:02o}"),
11301129
};
11311130

11321131
// Fetch the current instruction into the N register.
@@ -1288,19 +1287,15 @@ impl ControlUnit {
12881287
details: AlarmDetails::QSAL(
12891288
self.regs.n,
12901289
BadMemOp::Read(Unsigned36Bit::from(addr)),
1291-
format!(
1292-
"memory unit indicated address {:o} is not mapped",
1293-
operand_address
1294-
),
1290+
format!("memory unit indicated address {operand_address:o} is not mapped",),
12951291
),
12961292
})?;
12971293
// QSAL is masked to we have to return some value, but
12981294
// we don't know what the TX-2 did in this case.
12991295
Err(self.alarm_unit.always_fire(Alarm {
13001296
sequence: self.regs.k,
13011297
details: AlarmDetails::ROUNDTUITAL(format!(
1302-
"memory unit indicated address {:o} is not mapped and we don't know what to do when QSAL is masked",
1303-
operand_address
1298+
"memory unit indicated address {operand_address:o} is not mapped and we don't know what to do when QSAL is masked",
13041299
))
13051300
}))
13061301
}
@@ -1335,7 +1330,7 @@ impl ControlUnit {
13351330
details: AlarmDetails::QSAL(
13361331
self.regs.n,
13371332
BadMemOp::Write(Unsigned36Bit::from(*target)),
1338-
format!("memory store to address {:#o} failed: {}", target, e,),
1333+
format!("memory store to address {target:#o} failed: {e}",),
13391334
),
13401335
})?;
13411336
Ok(()) // QSAL is masked, so just carry on.

cpu/src/control/op_configuration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ mod tests {
124124
.update_n_register(Instruction::from(&inst).bits())
125125
.expect(COMPLAIN);
126126
if let Err(e) = control.op_spg(ctx, &mut mem) {
127-
panic!("SPG instruction failed: {}", e);
127+
panic!("SPG instruction failed: {e}");
128128
}
129129

130130
(

cpu/src/control/op_index.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ mod tests {
411411
.update_n_register(Instruction::from(&inst).bits())
412412
.expect(COMPLAIN);
413413
if let Err(e) = control.op_aux(ctx, &mut mem) {
414-
panic!("AUX instruction failed: {}", e);
414+
panic!("AUX instruction failed: {e}");
415415
}
416416
}
417417
(control.regs.get_index_register(j), mem.get_e_register())
@@ -659,7 +659,7 @@ mod tests {
659659
.update_n_register(Instruction::from(&inst).bits())
660660
.expect(COMPLAIN);
661661
if let Err(e) = control.op_rsx(ctx, &mut mem) {
662-
panic!("RSX instruction failed: {}", e);
662+
panic!("RSX instruction failed: {e}");
663663
}
664664
(control.regs.get_index_register(j), mem.get_e_register())
665665
}

cpu/src/control/op_io.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ impl ControlUnit {
114114
Err(self.alarm_unit.always_fire(Alarm {
115115
sequence: self.regs.k,
116116
details: AlarmDetails::ROUNDTUITAL(format!(
117-
"IOS operand {:o}: Select Unit command is not yet implemented.",
118-
operand
117+
"IOS operand {operand:o}: Select Unit command is not yet implemented.",
119118
)),
120119
}))
121120
}
@@ -127,8 +126,7 @@ impl ControlUnit {
127126
unit: j,
128127
operand: Some(operand),
129128
message: format!(
130-
"IOS operand {:o} has unrecognised leading command digit {:o}",
131-
operand, command,
129+
"IOS operand {operand:o} has unrecognised leading command digit {command:o}",
132130
),
133131
},
134132
})?;

cpu/src/control/op_jump.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ impl ControlUnit {
137137
self.regs.n,
138138
BadMemOp::Write(target.into()),
139139
format!(
140-
"SKM instruction attempted to access address {:o} but it is not mapped",
141-
addr,
140+
"SKM instruction attempted to access address {addr:o} but it is not mapped",
142141
),
143142
),
144143
})?;
@@ -153,9 +152,7 @@ impl ControlUnit {
153152
self.regs.n,
154153
BadMemOp::Write(target.into()),
155154
format!(
156-
"SKM instruction attempted to modify (instruction configuration={:o}) a read-only location {:o}",
157-
cf,
158-
target,
155+
"SKM instruction attempted to modify (instruction configuration={cf:o}) a read-only location {target:o}",
159156
),
160157
)
161158
})?;
@@ -311,7 +308,7 @@ mod tests {
311308
let result = control.op_jmp(ctx, &mut mem);
312309
match result {
313310
Err(e) => {
314-
panic!("JMP instruction failed: {}", e);
311+
panic!("JMP instruction failed: {e}");
315312
}
316313
Ok(OpcodeResult {
317314
program_counter_change: Some(ProgramCounterChange::Jump(to)),
@@ -857,14 +854,14 @@ mod tests {
857854
&UpdateE::No,
858855
&MetaBitChange::None,
859856
) {
860-
return Err(format!("failed to set up memory contents: {}", e));
857+
return Err(format!("failed to set up memory contents: {e}"));
861858
}
862859
control
863860
.update_n_register(Instruction::from(inst).bits())
864861
.expect(COMPLAIN);
865862
let result = match control.op_sed(ctx, &mut mem) {
866863
Err(e) => {
867-
return Err(format!("Execution of SED instruction failed: {}", e));
864+
return Err(format!("Execution of SED instruction failed: {e}"));
868865
}
869866
Ok(result) => result,
870867
};
@@ -897,8 +894,7 @@ mod tests {
897894
"SED instruction should not cause the current sequence's flag to drop".to_string(),
898895
),
899896
Some(ProgramCounterChange::Stop(addr)) => Err(format!(
900-
"SED instruction execution stopped at address {:?}",
901-
addr
897+
"SED instruction execution stopped at address {addr:?}",
902898
)),
903899
}
904900
}
@@ -917,7 +913,7 @@ mod tests {
917913
panic!("{}", err);
918914
}
919915
Ok((Some(alarm), _)) => {
920-
panic!("SED instruction unexpectedly raised an alarm {}", alarm);
916+
panic!("SED instruction unexpectedly raised an alarm {alarm}");
921917
}
922918
Ok((None, skip)) => skip,
923919
}

cpu/src/control/op_loadstore.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ mod tests {
334334
ArithmeticUnitRegister::E => control.op_lde(ctx, &mut mem),
335335
};
336336
if let Err(e) = result {
337-
panic!("{:?} instruction failed: {}", opcode, e);
337+
panic!("{opcode:?} instruction failed: {e}");
338338
}
339339
(
340340
get_register_value(&mem, target_register),
@@ -386,7 +386,7 @@ mod tests {
386386
defer: bool,
387387
configuration: SystemConfiguration,
388388
) -> (Unsigned36Bit, Unsigned36Bit) {
389-
let complain = format!("failed to execute store instruction {:?}", opcode);
389+
let complain = format!("failed to execute store instruction {opcode:?}");
390390
control.regs.f_memory[1] = configuration;
391391
let inst = SymbolicInstruction {
392392
held: false,
@@ -405,16 +405,16 @@ mod tests {
405405
let f = match opcode {
406406
Opcode::Ste => ControlUnit::op_ste,
407407
_ => {
408-
panic!("opcode {:?} is not yet supported", opcode);
408+
panic!("opcode {opcode:?} is not yet supported");
409409
}
410410
};
411411
if let Err(e) = f(control, ctx, mem) {
412-
panic!("{:?} instruction failed: {}", opcode, e);
412+
panic!("{opcode:?} instruction failed: {e}");
413413
}
414414
match mem.fetch(ctx, working_address, &MetaBitChange::None) {
415415
Ok((stored, _)) => (stored, mem.get_e_register()),
416416
Err(e) => {
417-
panic!("unable to retrieve the stored word: {}", e);
417+
panic!("unable to retrieve the stored word: {e}");
418418
}
419419
}
420420
}

cpu/src/exchanger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl QuarterActivity {
4141
}
4242

4343
pub(crate) fn is_active(&self, q: &u8) -> bool {
44-
assert!(*q < 4, "invalid quarter {}", q);
44+
assert!(*q < 4, "invalid quarter {q}");
4545
let mask = 1 << *q;
4646
self.0 & mask != 0
4747
}

cpu/src/io.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl Display for TransferFailed {
9191
TransferFailed::BufferNotFree => {
9292
f.write_str("Unit buffer not available for use by the CPU")
9393
}
94-
TransferFailed::Alarm(alarm) => write!(f, "{}", alarm),
94+
TransferFailed::Alarm(alarm) => write!(f, "{alarm}"),
9595
}
9696
}
9797
}
@@ -571,7 +571,7 @@ impl DeviceManager {
571571
details: AlarmDetails::IOSAL {
572572
unit,
573573
operand: None,
574-
message: format!("unit {:o} is not known", unit),
574+
message: format!("unit {unit:o} is not known"),
575575
},
576576
})?;
577577
// IOSAL is masked.
@@ -668,7 +668,7 @@ impl DeviceManager {
668668
details: AlarmDetails::IOSAL {
669669
unit: devno,
670670
operand: None,
671-
message: format!("unit {} reports inability (EIA)", devno),
671+
message: format!("unit {devno:o} reports inability (EIA)"),
672672
},
673673
});
674674
} else if unit_status.missed_data {
@@ -734,7 +734,7 @@ impl DeviceManager {
734734
details: AlarmDetails::IOSAL {
735735
unit: *device,
736736
operand: None,
737-
message: format!("Attempt to disconnect missing unit {}", device),
737+
message: format!("Attempt to disconnect missing unit {device:o}"),
738738
},
739739
})?;
740740
Ok(()) // IOSAL is masked, carry on.
@@ -763,7 +763,7 @@ impl DeviceManager {
763763
details: AlarmDetails::IOSAL {
764764
unit: *device,
765765
operand: None,
766-
message: format!("Attempt to connect in-maint unit {}", device),
766+
message: format!("Attempt to connect in-maint unit {device:o}"),
767767
},
768768
})
769769
} else {
@@ -783,7 +783,7 @@ impl DeviceManager {
783783
details: AlarmDetails::IOSAL {
784784
unit: *device,
785785
operand: None,
786-
message: format!("Attempt to connect missing unit {}", device),
786+
message: format!("Attempt to connect missing unit {device:o}"),
787787
},
788788
})?;
789789
Ok(None) // IOSAL is masked, carry on

cpu/src/memory.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ impl Display for MemoryOpFailure {
6464
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
6565
match self {
6666
MemoryOpFailure::NotMapped(addr) => {
67-
write!(f, "address {:o} is not mapped to functioning memory", addr)
67+
write!(f, "address {addr:o} is not mapped to functioning memory")
6868
}
6969
MemoryOpFailure::ReadOnly(addr, _extra) => {
70-
write!(f, "address {:o}is mapped to read-only memory", addr)
70+
write!(f, "address {addr:o}is mapped to read-only memory")
7171
}
7272
}
7373
}
@@ -1159,7 +1159,7 @@ fn test_write_all_mem() {
11591159
}
11601160
Err(MemoryOpFailure::NotMapped(_)) => (),
11611161
Err(e) => {
1162-
panic!("Failure {:?} during write of memory address {:o}", e, addr);
1162+
panic!("Failure {e:?} during write of memory address {addr:o}");
11631163
}
11641164
}
11651165
}
@@ -1184,7 +1184,7 @@ fn test_read_all_mem() {
11841184
Ok(_) => (),
11851185
Err(MemoryOpFailure::NotMapped(_)) => (),
11861186
Err(e) => {
1187-
panic!("Failure {:?} during read of memory address {:o}", e, addr);
1187+
panic!("Failure {e:?} during read of memory address {addr:o}");
11881188
}
11891189
}
11901190
}

0 commit comments

Comments
 (0)