Skip to content

Commit 7c97fd4

Browse files
committed
[base] Fix some new clippy warnings (following rustup update).
1 parent 590bc7e commit 7c97fd4

File tree

10 files changed

+46
-86
lines changed

10 files changed

+46
-86
lines changed

base/src/charset.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ impl Display for LincolnToUnicodeStrictConversionFailure {
138138
) => {
139139
write!(
140140
f,
141-
"cannot convert code {:#o} from Lincoln Writer character set to Unicode, because it has no printable representation",
142-
n
141+
"cannot convert code {n:#o} from Lincoln Writer character set to Unicode, because it has no printable representation",
143142
)
144143
}
145144
LincolnToUnicodeStrictConversionFailure::CannotSubscript(
@@ -148,9 +147,7 @@ impl Display for LincolnToUnicodeStrictConversionFailure {
148147
) => {
149148
write!(
150149
f,
151-
"cannot convert {:#o} from Lincoln Writer character set to Unicode, because Unicode has no subscript form of '{}'",
152-
u,
153-
ch
150+
"cannot convert {u:#o} from Lincoln Writer character set to Unicode, because Unicode has no subscript form of '{ch}'",
154151
)
155152
}
156153
LincolnToUnicodeStrictConversionFailure::CannotSuperscript(
@@ -159,9 +156,7 @@ impl Display for LincolnToUnicodeStrictConversionFailure {
159156
) => {
160157
write!(
161158
f,
162-
"cannot convert {:#o} from Lincoln Writer character set to Unicode, because Unicode has no superscript form of '{}'",
163-
u,
164-
ch
159+
"cannot convert {u:#o} from Lincoln Writer character set to Unicode, because Unicode has no superscript form of '{ch}'",
165160
)
166161
}
167162
}
@@ -620,8 +615,7 @@ impl Display for UnicodeToLincolnConversionFailure {
620615
UnicodeToLincolnConversionFailure::NoMapping(ch) => {
621616
write!(
622617
f,
623-
"there is no mapping for '{}' from Unicode to Lincoln Writer character set",
624-
ch,
618+
"there is no mapping for '{ch}' from Unicode to Lincoln Writer character set",
625619
)
626620
}
627621
}

base/src/charset/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ fn round_trip() {
7777
assert_eq!(input, s);
7878
}
7979
Err(e) => {
80-
panic!("failed to convert back to unicode: {}", e);
80+
panic!("failed to convert back to unicode: {e}");
8181
}
8282
},
8383
Err(e) => {
84-
panic!("failed to convert [{}] to Lincoln: {}", input, e);
84+
panic!("failed to convert [{input}] to Lincoln: {e}");
8585
}
8686
}
8787
}

base/src/instruction.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ impl From<Instruction> for Unsigned36Bit {
139139
impl Debug for Instruction {
140140
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
141141
let lhs = match SymbolicInstruction::try_from(self) {
142-
Ok(sym) => format!("{}", sym),
143-
Err(e) => format!("(invalid instruction: {})", e),
142+
Ok(sym) => format!("{sym}"),
143+
Err(e) => format!("(invalid instruction: {e})"),
144144
};
145145
write!(f, "{:<40} {}", lhs, self.0)
146146
}
@@ -510,7 +510,7 @@ impl Debug for DisassemblyFailure {
510510
n
511511
}
512512
};
513-
write!(f, "(0{:o})", opcode)
513+
write!(f, "(0{opcode:o})")
514514
}
515515
}
516516

base/src/instruction/format.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ impl Octal for OperandAddress {
109109
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
110110
match self {
111111
OperandAddress::Direct(addr) => {
112-
write!(f, "{:o}", addr)
112+
write!(f, "{addr:o}")
113113
}
114114
OperandAddress::Deferred(addr) => {
115-
write!(f, "[{:o}]", addr)
115+
write!(f, "[{addr:o}]")
116116
}
117117
}
118118
}
@@ -130,20 +130,20 @@ impl Display for DisassemblyFailure {
130130
n
131131
}
132132
};
133-
write!(f, " {:03o}", opcode)
133+
write!(f, " {opcode:03o}")
134134
}
135135
}
136136

137137
fn octal_superscript_u8(n: u8) -> Result<String, NoSuperscriptKnown> {
138-
format!("{:o}", n).chars().map(superscript_char).collect()
138+
format!("{n:o}").chars().map(superscript_char).collect()
139139
}
140140

141141
fn subscript(s: &str) -> Result<String, NoSubscriptKnown> {
142142
s.chars().map(subscript_char).collect()
143143
}
144144

145145
fn octal_subscript_number(n: u8) -> String {
146-
subscript(&format!("{:o}", n)).unwrap()
146+
subscript(&format!("{n:o}")).unwrap()
147147
}
148148

149149
fn write_opcode(op: Opcode, cfg: Unsigned5Bit, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
@@ -204,7 +204,7 @@ fn write_opcode(op: Opcode, cfg: Unsigned5Bit, f: &mut Formatter<'_>) -> Result<
204204
0o14 => "SUR",
205205
_ => "SKM",
206206
}),
207-
_ => write!(f, "{}", op),
207+
_ => write!(f, "{op}"),
208208
}
209209
}
210210

base/src/onescomplement/signed/tests18.rs

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,7 @@ fn test_i8_round_tripping() {
8686
if let Some(qprev) = prev {
8787
assert!(
8888
q > qprev,
89-
"failed to round-trip {}: {:?} should be greater than {:?}",
90-
i,
91-
q,
92-
qprev
89+
"failed to round-trip {i}: {q:?} should be greater than {qprev:?}",
9390
);
9491
}
9592
prev = Some(q);
@@ -99,8 +96,8 @@ fn test_i8_round_tripping() {
9996
}
10097
Err(e) => {
10198
panic!(
102-
"Unexpected overflow when round-tripping {}->{:?}-> [conversion to i8 failed with error {}]",
103-
i, &q, e);
99+
"Unexpected overflow when round-tripping {}->{:?}-> [conversion to i8 failed with error {}]",
100+
i, &q, e);
104101
}
105102
}
106103
}
@@ -114,10 +111,7 @@ fn test_i16_round_tripping() {
114111
if let Some(qprev) = prev {
115112
assert!(
116113
q > qprev,
117-
"failed to round-trip {}: {:?} should be greater than {:?}",
118-
i,
119-
q,
120-
qprev
114+
"failed to round-trip {i}: {q:?} should be greater than {qprev:?}",
121115
);
122116
}
123117
prev = Some(q);
@@ -127,8 +121,8 @@ fn test_i16_round_tripping() {
127121
}
128122
Err(e) => {
129123
panic!(
130-
"Unexpected overflow when round-tripping {}->{:?}-> [conversion to i8 failed with error {}]",
131-
i, &q, e);
124+
"Unexpected overflow when round-tripping {}->{:?}-> [conversion to i8 failed with error {}]",
125+
i, &q, e);
132126
}
133127
}
134128
}
@@ -142,10 +136,7 @@ fn test_u8_round_tripping() {
142136
if let Some(qprev) = prev {
143137
assert!(
144138
q > qprev,
145-
"failed to round-trip {}: {:?} should be greater than {:?}",
146-
i,
147-
q,
148-
qprev
139+
"failed to round-trip {i}: {q:?} should be greater than {qprev:?}",
149140
);
150141
}
151142
prev = Some(q);
@@ -155,8 +146,8 @@ fn test_u8_round_tripping() {
155146
}
156147
Err(e) => {
157148
panic!(
158-
"Unexpected overflow when round-tripping {}->{:?}-> [conversion to i8 failed with error {}]",
159-
i, &q, e);
149+
"Unexpected overflow when round-tripping {}->{:?}-> [conversion to i8 failed with error {}]",
150+
i, &q, e);
160151
}
161152
}
162153
}
@@ -170,10 +161,7 @@ fn test_u16_round_tripping() {
170161
if let Some(qprev) = prev {
171162
assert!(
172163
q > qprev,
173-
"failed to round-trip {}: {:?} should be greater than {:?}",
174-
i,
175-
q,
176-
qprev
164+
"failed to round-trip {i}: {q:?} should be greater than {qprev:?}",
177165
);
178166
}
179167
prev = Some(q);
@@ -183,8 +171,8 @@ fn test_u16_round_tripping() {
183171
}
184172
Err(e) => {
185173
panic!(
186-
"Unexpected overflow when round-tripping {}->{:?}-> [conversion to i8 failed with error {}]",
187-
i, &q, e);
174+
"Unexpected overflow when round-tripping {}->{:?}-> [conversion to i8 failed with error {}]",
175+
i, &q, e);
188176
}
189177
}
190178
}
@@ -322,8 +310,8 @@ fn test_from_signed18bit_to_i16() {
322310

323311
#[test]
324312
fn test_from_u16_to_signed18bit() {
325-
assert_eq!(Signed18Bit::try_from(0_u16), Ok(Signed18Bit::ZERO));
326-
assert_eq!(Signed18Bit::try_from(1_u16), Ok(Signed18Bit::ONE));
313+
assert_eq!(Signed18Bit::from(0_u16), Signed18Bit::ZERO);
314+
assert_eq!(Signed18Bit::from(1_u16), Signed18Bit::ONE);
327315
assert_eq!(Signed18Bit::from(0o377_u16).bits, 0o000_000_377_u32);
328316
}
329317

base/src/onescomplement/signed/tests36.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@ fn test_i16_round_tripping() {
6666
if let Some(qprev) = prev {
6767
assert!(
6868
q > qprev,
69-
"failed to round-trip {}: {:?} should be greater than {:?}",
70-
i,
71-
q,
72-
qprev
69+
"failed to round-trip {i}: {q:?} should be greater than {qprev:?}",
7370
);
7471
}
7572
prev = Some(q);

base/src/onescomplement/signed/tests5.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ fn test_i8_round_tripping() {
1717
if let Some(qprev) = prev {
1818
assert!(
1919
q > qprev,
20-
"failed to round-trip {}: {:?} should be greater than {:?}",
21-
i,
22-
q,
23-
qprev
20+
"failed to round-trip {i}: {q:?} should be greater than {qprev:?}",
2421
);
2522
}
2623
prev = Some(q);

base/src/onescomplement/signed/tests9.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ fn test_i8_round_tripping() {
5555
if let Some(qprev) = prev {
5656
assert!(
5757
q > qprev,
58-
"failed to round-trip {}: {:?} should be greater than {:?}",
59-
i,
60-
q,
61-
qprev
58+
"failed to round-trip {i}: {q:?} should be greater than {qprev:?}",
6259
);
6360
}
6461
prev = Some(q);
@@ -68,8 +65,8 @@ fn test_i8_round_tripping() {
6865
}
6966
Err(e) => {
7067
panic!(
71-
"Unexpected overflow when round-tripping {}->{:?}-> [conversion to i8 failed with error {}]",
72-
i, &q, e);
68+
"Unexpected overflow when round-tripping {}->{:?}-> [conversion to i8 failed with error {}]",
69+
i, &q, e);
7370
}
7471
}
7572
}
@@ -83,10 +80,7 @@ fn test_u8_round_tripping() {
8380
if let Some(qprev) = prev {
8481
assert!(
8582
q > qprev,
86-
"failed to round-trip {}: {:?} should be greater than {:?}",
87-
i,
88-
q,
89-
qprev
83+
"failed to round-trip {i}: {q:?} should be greater than {qprev:?}",
9084
);
9185
}
9286
prev = Some(q);
@@ -96,8 +90,8 @@ fn test_u8_round_tripping() {
9690
}
9791
Err(e) => {
9892
panic!(
99-
"Unexpected overflow when round-tripping {}->{:?}-> [conversion to i8 failed with error {}]",
100-
i, &q, e);
93+
"Unexpected overflow when round-tripping {}->{:?}-> [conversion to i8 failed with error {}]",
94+
i, &q, e);
10195
}
10296
}
10397
}
@@ -319,8 +313,7 @@ fn test_wrapping_add() {
319313

320314
assert_eq!(
321315
expected, got,
322-
"Expected {} + {} = {}, got {:?} + {:?} = {}",
323-
left, right, expected, left_operand, right_operand, got
316+
"Expected {left} + {right} = {expected}, got {left_operand:?} + {right_operand:?} = {got}",
324317
);
325318
}
326319
}
@@ -339,8 +332,7 @@ fn test_wrapping_sub() {
339332

340333
assert_eq!(
341334
expected, got,
342-
"Expected {} + {} = {}, got {:?} + {:?} = {}",
343-
left, right, expected, left_operand, right_operand, got
335+
"Expected {left} + {right} = {expected}, got {left_operand:?} + {right_operand:?} = {got}",
344336
);
345337
}
346338
}

base/src/onescomplement/unsigned/tests.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,7 @@ fn test_i8_round_tripping() {
6969
if let Some(qprev) = prev {
7070
assert!(
7171
q > qprev,
72-
"failed to round-trip {}: {:?} should be greater than {:?}",
73-
i,
74-
q,
75-
qprev
72+
"failed to round-trip {i}: {q:?} should be greater than {qprev:?}",
7673
);
7774
}
7875
prev = Some(q);
@@ -97,10 +94,7 @@ fn test_u8_round_tripping() {
9794
if let Some(qprev) = prev {
9895
assert!(
9996
q > qprev,
100-
"failed to round-trip {}: {:?} should be greater than {:?}",
101-
i,
102-
q,
103-
qprev
97+
"failed to round-trip {i}: {q:?} should be greater than {qprev:?}",
10498
);
10599
}
106100
prev = Some(q);
@@ -151,7 +145,7 @@ fn test_unsigned9bit_zero_values() {
151145
const CAREFUL_NOW: Unsigned9Bit = Unsigned9Bit {
152146
bits: 0b111_111_111_u16,
153147
};
154-
assert_eq!(u16::try_from(CAREFUL_NOW), Ok(0o777));
148+
assert_eq!(u16::from(CAREFUL_NOW), 0o777);
155149
}
156150

157151
#[test]

base/src/splay.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,15 @@ fn round_trip(input: Unsigned36Bit) -> Result<(), String> {
147147
for (i, component) in unsplayed.into_iter().enumerate() {
148148
let next = cycle_and_splay(output, component);
149149
println!(
150-
"round_trip: splay iteration {}: value {:03o} changed word from {:012o} to {:012o}",
151-
i, component, output, next
150+
"round_trip: splay iteration {i}: value {component:03o} changed word from {output:012o} to {next:012o}",
152151
);
153152
output = next;
154153
}
155154
dbg!(&output);
156155
if input == output {
157156
Ok(())
158157
} else {
159-
Err(format!("mismatch: input word {:012o} unsplayed to {:?}, which splayed to {:012o}, which doesn't match",
160-
input, unsplayed, output))
158+
Err(format!("mismatch: input word {input:012o} unsplayed to {unsplayed:?}, which splayed to {output:012o}, which doesn't match",))
161159
}
162160
}
163161

@@ -176,7 +174,7 @@ fn test_round_trip_selected() {
176174
Unsigned36Bit::from(0o23574373_u32),
177175
] {
178176
if let Err(e) = round_trip(value) {
179-
panic!("round_trip failed for {:012o}: {}", value, e);
177+
panic!("round_trip failed for {value:012o}: {e}");
180178
}
181179
}
182180
}
@@ -186,7 +184,7 @@ fn test_round_trip_bitcycle() {
186184
for bitpos in 0..36 {
187185
let input: Unsigned36Bit = Unsigned36Bit::ONE.shl(bitpos);
188186
if let Err(e) = round_trip(input) {
189-
panic!("round_trip failed for {:012o}: {}", input, e);
187+
panic!("round_trip failed for {input:012o}: {e}");
190188
}
191189
}
192190
}

0 commit comments

Comments
 (0)