Skip to content

Commit c59e0a3

Browse files
authored
pulley: Remove unwrap_uninhabited helper function (#10174)
No longer needed on our MSRV any more.
1 parent 0e05600 commit c59e0a3

File tree

4 files changed

+8
-19
lines changed

4 files changed

+8
-19
lines changed

pulley/src/decode.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -710,14 +710,6 @@ macro_rules! define_extended_decoder {
710710
}
711711
for_each_extended_op!(define_extended_decoder);
712712

713-
/// Unwrap a `Result<T, Uninhabited>`.
714-
/// Always succeeds, since `Uninhabited` is uninhabited.
715-
pub fn unwrap_uninhabited<T>(res: Result<T, Uninhabited>) -> T {
716-
match res {
717-
Ok(ok) => ok,
718-
}
719-
}
720-
721713
/// Functions for decoding the operands of an instruction, assuming the opcode
722714
/// has already been decoded.
723715
pub mod operands {

pulley/src/interp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2084,7 +2084,7 @@ impl OpVisitor for Interpreter<'_> {
20842084
// Decode the `PcRelOffset` without tampering with `self.pc` as the
20852085
// jump is relative to `self.pc`.
20862086
let mut tmp = self.pc;
2087-
let rel = unwrap_uninhabited(PcRelOffset::decode(&mut tmp));
2087+
let Ok(rel) = PcRelOffset::decode(&mut tmp);
20882088
let offset = isize::try_from(i32::from(rel)).unwrap();
20892089
self.pc = unsafe { self.pc.offset(offset) };
20902090
ControlFlow::Continue(())

pulley/src/interp/match_loop.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
//! will probably need tweaks to make it more performant.
1717
1818
use super::*;
19-
use crate::decode::unwrap_uninhabited;
2019

2120
impl Interpreter<'_> {
2221
pub fn run(self) -> Done {
@@ -30,9 +29,9 @@ impl Interpreter<'_> {
3029
//
3130
// This will then continue indefinitely until the bytecode says it's
3231
// done. Note that only trusted bytecode is interpreted here.
33-
match unwrap_uninhabited(decoder.decode_one(&mut visitor)) {
34-
ControlFlow::Continue(()) => {}
35-
ControlFlow::Break(done) => break done,
32+
match decoder.decode_one(&mut visitor) {
33+
Ok(ControlFlow::Continue(())) => {}
34+
Ok(ControlFlow::Break(done)) => break done,
3635
}
3736
}
3837
}

pulley/src/interp/tail_loop.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
//! at this time but doesn't actually run anywhere.
2828
2929
use super::*;
30-
use crate::decode::{unwrap_uninhabited, ExtendedOpVisitor};
30+
use crate::decode::ExtendedOpVisitor;
3131
use crate::opcode::Opcode;
3232
use crate::profile::ExecutingPcRef;
3333
use crate::ExtendedOpcode;
@@ -90,7 +90,7 @@ fn dispatch(
9090
// opcode.
9191
let mut debug = debug(state, pc, executing_pc);
9292
debug.before_visit();
93-
let opcode = unwrap_uninhabited(Opcode::decode(debug.bytecode()));
93+
let Ok(opcode) = Opcode::decode(debug.bytecode());
9494
let handler = OPCODE_HANDLER_TABLE[opcode as usize];
9595
tail_call!(handler(debug.0.state, debug.0.pc, debug.0.executing_pc));
9696
}
@@ -102,7 +102,7 @@ fn run_extended(
102102
pc_ref: ExecutingPcRef<'_>,
103103
) -> Done {
104104
let mut i = debug(state, pc, pc_ref);
105-
let opcode = unwrap_uninhabited(ExtendedOpcode::decode(i.bytecode()));
105+
let Ok(opcode) = ExtendedOpcode::decode(i.bytecode());
106106
let handler = EXTENDED_OPCODE_HANDLER_TABLE[opcode as usize];
107107
tail_call!(handler(i.0.state, i.0.pc, i.0.executing_pc));
108108
}
@@ -171,9 +171,7 @@ macro_rules! define_opcode_handler {
171171
) -> Done {
172172
let mut debug = debug(state, pc, executing_pc);
173173
$(
174-
let ($($field,)*) = unwrap_uninhabited(
175-
crate::decode::operands::$snake_name(debug.0.bytecode())
176-
);
174+
let Ok(($($field,)*)) = crate::decode::operands::$snake_name(debug.0.bytecode());
177175
)?
178176
let result = debug.$snake_name($($($field),*)?);
179177
debug.after_visit();

0 commit comments

Comments
 (0)