Revert signature change for AssertMessage description
This commit is contained in:
parent
c0f1207a12
commit
600438679d
@ -4,7 +4,6 @@
|
|||||||
VariantIdx,
|
VariantIdx,
|
||||||
};
|
};
|
||||||
use crate::{Error, Opaque, Span, Symbol};
|
use crate::{Error, Opaque, Span, Symbol};
|
||||||
use std::borrow::Cow;
|
|
||||||
use std::io;
|
use std::io;
|
||||||
/// The SMIR representation of a single function.
|
/// The SMIR representation of a single function.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
@ -265,63 +264,51 @@ pub enum AssertMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AssertMessage {
|
impl AssertMessage {
|
||||||
pub fn description(&self) -> Result<Cow<'static, str>, Error> {
|
pub fn description(&self) -> Result<&'static str, Error> {
|
||||||
match self {
|
match self {
|
||||||
AssertMessage::Overflow(BinOp::Add, _, _) => Ok("attempt to add with overflow".into()),
|
AssertMessage::Overflow(BinOp::Add, _, _) => Ok("attempt to add with overflow"),
|
||||||
AssertMessage::Overflow(BinOp::Sub, _, _) => {
|
AssertMessage::Overflow(BinOp::Sub, _, _) => Ok("attempt to subtract with overflow"),
|
||||||
Ok("attempt to subtract with overflow".into())
|
AssertMessage::Overflow(BinOp::Mul, _, _) => Ok("attempt to multiply with overflow"),
|
||||||
}
|
AssertMessage::Overflow(BinOp::Div, _, _) => Ok("attempt to divide with overflow"),
|
||||||
AssertMessage::Overflow(BinOp::Mul, _, _) => {
|
|
||||||
Ok("attempt to multiply with overflow".into())
|
|
||||||
}
|
|
||||||
AssertMessage::Overflow(BinOp::Div, _, _) => {
|
|
||||||
Ok("attempt to divide with overflow".into())
|
|
||||||
}
|
|
||||||
AssertMessage::Overflow(BinOp::Rem, _, _) => {
|
AssertMessage::Overflow(BinOp::Rem, _, _) => {
|
||||||
Ok("attempt to calculate the remainder with overflow".into())
|
Ok("attempt to calculate the remainder with overflow")
|
||||||
}
|
|
||||||
AssertMessage::OverflowNeg(_) => Ok("attempt to negate with overflow".into()),
|
|
||||||
AssertMessage::Overflow(BinOp::Shr, _, _) => {
|
|
||||||
Ok("attempt to shift right with overflow".into())
|
|
||||||
}
|
|
||||||
AssertMessage::Overflow(BinOp::Shl, _, _) => {
|
|
||||||
Ok("attempt to shift left with overflow".into())
|
|
||||||
}
|
}
|
||||||
|
AssertMessage::OverflowNeg(_) => Ok("attempt to negate with overflow"),
|
||||||
|
AssertMessage::Overflow(BinOp::Shr, _, _) => Ok("attempt to shift right with overflow"),
|
||||||
|
AssertMessage::Overflow(BinOp::Shl, _, _) => Ok("attempt to shift left with overflow"),
|
||||||
AssertMessage::Overflow(op, _, _) => Err(error!("`{:?}` cannot overflow", op)),
|
AssertMessage::Overflow(op, _, _) => Err(error!("`{:?}` cannot overflow", op)),
|
||||||
AssertMessage::DivisionByZero(_) => Ok("attempt to divide by zero".into()),
|
AssertMessage::DivisionByZero(_) => Ok("attempt to divide by zero"),
|
||||||
AssertMessage::RemainderByZero(_) => {
|
AssertMessage::RemainderByZero(_) => {
|
||||||
Ok("attempt to calculate the remainder with a divisor of zero".into())
|
Ok("attempt to calculate the remainder with a divisor of zero")
|
||||||
}
|
}
|
||||||
AssertMessage::ResumedAfterReturn(CoroutineKind::Coroutine) => {
|
AssertMessage::ResumedAfterReturn(CoroutineKind::Coroutine) => {
|
||||||
Ok("coroutine resumed after completion".into())
|
Ok("coroutine resumed after completion")
|
||||||
}
|
}
|
||||||
AssertMessage::ResumedAfterReturn(CoroutineKind::Async(_)) => {
|
AssertMessage::ResumedAfterReturn(CoroutineKind::Async(_)) => {
|
||||||
Ok("`async fn` resumed after completion".into())
|
Ok("`async fn` resumed after completion")
|
||||||
}
|
}
|
||||||
AssertMessage::ResumedAfterReturn(CoroutineKind::Gen(_)) => {
|
AssertMessage::ResumedAfterReturn(CoroutineKind::Gen(_)) => {
|
||||||
Ok("`async gen fn` resumed after completion".into())
|
Ok("`async gen fn` resumed after completion")
|
||||||
}
|
}
|
||||||
AssertMessage::ResumedAfterReturn(CoroutineKind::AsyncGen(_)) => {
|
AssertMessage::ResumedAfterReturn(CoroutineKind::AsyncGen(_)) => {
|
||||||
Ok("`gen fn` should just keep returning `AssertMessage::None` after completion"
|
Ok("`gen fn` should just keep returning `AssertMessage::None` after completion")
|
||||||
.into())
|
|
||||||
}
|
}
|
||||||
AssertMessage::ResumedAfterPanic(CoroutineKind::Coroutine) => {
|
AssertMessage::ResumedAfterPanic(CoroutineKind::Coroutine) => {
|
||||||
Ok("coroutine resumed after panicking".into())
|
Ok("coroutine resumed after panicking")
|
||||||
}
|
}
|
||||||
AssertMessage::ResumedAfterPanic(CoroutineKind::Async(_)) => {
|
AssertMessage::ResumedAfterPanic(CoroutineKind::Async(_)) => {
|
||||||
Ok("`async fn` resumed after panicking".into())
|
Ok("`async fn` resumed after panicking")
|
||||||
}
|
}
|
||||||
AssertMessage::ResumedAfterPanic(CoroutineKind::Gen(_)) => {
|
AssertMessage::ResumedAfterPanic(CoroutineKind::Gen(_)) => {
|
||||||
Ok("`async gen fn` resumed after panicking".into())
|
Ok("`async gen fn` resumed after panicking")
|
||||||
}
|
}
|
||||||
AssertMessage::ResumedAfterPanic(CoroutineKind::AsyncGen(_)) => {
|
AssertMessage::ResumedAfterPanic(CoroutineKind::AsyncGen(_)) => {
|
||||||
Ok("`gen fn` should just keep returning `AssertMessage::None` after panicking"
|
Ok("`gen fn` should just keep returning `AssertMessage::None` after panicking")
|
||||||
.into())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AssertMessage::BoundsCheck { .. } => Ok("index out of bounds".into()),
|
AssertMessage::BoundsCheck { .. } => Ok("index out of bounds"),
|
||||||
AssertMessage::MisalignedPointerDereference { .. } => {
|
AssertMessage::MisalignedPointerDereference { .. } => {
|
||||||
Ok("misaligned pointer dereference".into())
|
Ok("misaligned pointer dereference")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user