-use crate::loc::{BaseTy, Ty};
+use crate::{
+ index::{BlockIdx, InstIdx},
+ loc::{BaseTy, Ty},
+};
use thiserror::Error;
#[derive(Debug, Error)]
ty: Option<Ty>,
expected_ty: Option<Ty>,
},
+ #[error("function doesn't have entry block")]
+ MissingEntryBlock,
+ #[error("instruction index is too big")]
+ InstIdxTooBig,
+ #[error("block has invalid start {start}, expected {expected_start}")]
+ BlockHasInvalidStart {
+ start: InstIdx,
+ expected_start: InstIdx,
+ },
+ #[error("block {block} doesn't contain any instructions")]
+ BlockIsEmpty { block: BlockIdx },
+ #[error("entry block must not have any block parameters")]
+ EntryBlockCantHaveParams,
+ #[error("entry block must not have any predecessors")]
+ EntryBlockCantHavePreds,
+ #[error("block end is out of range: {end}")]
+ BlockEndOutOfRange { end: InstIdx },
+ #[error("block's last instruction must be a block terminator: {term_idx}")]
+ BlocksLastInstMustBeTerm { term_idx: InstIdx },
+ #[error(
+ "block terminator instructions are only allowed as a block's last instruction: {inst_idx}"
+ )]
+ TermInstOnlyAllowedAtBlockEnd { inst_idx: InstIdx },
}
pub type Result<T, E = Error> = std::result::Result<T, E>;