Skip to content

Commit

Permalink
Add From<Infallible> impl for PanicReason (#36)
Browse files Browse the repository at this point in the history
Some implementations in the interpreter benefir from the standard lib
`Infallible` implementation for errors that won't ever happen, except
for critical OS failures that are beyond the runtime control scope.

PanicReason should derive an implementation of infallible, and panic in
case it is ever reached.
  • Loading branch information
vlopes11 authored and xgreenx committed Dec 20, 2022
1 parent 767b369 commit 11c6b33
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion fuel-asm/src/panic_reason.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use core::fmt;
use core::{convert, fmt};

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(
Expand Down Expand Up @@ -534,3 +534,9 @@ impl std::error::Error for PanicReason {
None
}
}

impl From<convert::Infallible> for PanicReason {
fn from(_i: convert::Infallible) -> Self {
unreachable!()
}
}

0 comments on commit 11c6b33

Please sign in to comment.