Skip to content

Commit

Permalink
remove miette from core crate
Browse files Browse the repository at this point in the history
  • Loading branch information
sergerad committed Jul 19, 2024
1 parent 70c8138 commit dfab88f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
31 changes: 18 additions & 13 deletions assembly/src/assembler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,8 +766,9 @@ impl Assembler {
context,
mast_forest_builder,
)? {
if let Some(basic_block_id) =
basic_block_builder.make_basic_block(mast_forest_builder)?
if let Some(basic_block_id) = basic_block_builder
.make_basic_block(mast_forest_builder)
.map_err(AssemblyError::from)?
{
mast_node_ids.push(basic_block_id);
}
Expand All @@ -779,8 +780,9 @@ impl Assembler {
Op::If {
then_blk, else_blk, ..
} => {
if let Some(basic_block_id) =
basic_block_builder.make_basic_block(mast_forest_builder)?
if let Some(basic_block_id) = basic_block_builder
.make_basic_block(mast_forest_builder)
.map_err(AssemblyError::from)?
{
mast_node_ids.push(basic_block_id);
}
Expand All @@ -794,14 +796,15 @@ impl Assembler {
let split_node =
MastNode::new_split(then_blk, else_blk, mast_forest_builder.forest());

mast_forest_builder.ensure_node(split_node)?
mast_forest_builder.ensure_node(split_node).map_err(AssemblyError::from)?
};
mast_node_ids.push(split_node_id);
}

Op::Repeat { count, body, .. } => {
if let Some(basic_block_id) =
basic_block_builder.make_basic_block(mast_forest_builder)?
if let Some(basic_block_id) = basic_block_builder
.make_basic_block(mast_forest_builder)
.map_err(AssemblyError::from)?
{
mast_node_ids.push(basic_block_id);
}
Expand All @@ -815,8 +818,9 @@ impl Assembler {
}

Op::While { body, .. } => {
if let Some(basic_block_id) =
basic_block_builder.make_basic_block(mast_forest_builder)?
if let Some(basic_block_id) = basic_block_builder
.make_basic_block(mast_forest_builder)
.map_err(AssemblyError::from)?
{
mast_node_ids.push(basic_block_id);
}
Expand All @@ -827,22 +831,23 @@ impl Assembler {
let loop_node_id = {
let loop_node =
MastNode::new_loop(loop_body_node_id, mast_forest_builder.forest());
mast_forest_builder.ensure_node(loop_node)?
mast_forest_builder.ensure_node(loop_node).map_err(AssemblyError::from)?
};
mast_node_ids.push(loop_node_id);
}
}
}

if let Some(basic_block_id) =
basic_block_builder.try_into_basic_block(mast_forest_builder)?
if let Some(basic_block_id) = basic_block_builder
.try_into_basic_block(mast_forest_builder)
.map_err(AssemblyError::from)?
{
mast_node_ids.push(basic_block_id);
}

Ok(if mast_node_ids.is_empty() {
let basic_block_node = MastNode::new_basic_block(vec![Operation::Noop]);
mast_forest_builder.ensure_node(basic_block_node)?
mast_forest_builder.ensure_node(basic_block_node).map_err(AssemblyError::from)?
} else {
combine_mast_node_ids(mast_node_ids, mast_forest_builder)?
})
Expand Down
1 change: 0 additions & 1 deletion assembly/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ pub enum AssemblyError {
#[diagnostic(transparent)]
Other(#[from] RelatedError),
#[error(transparent)]
#[diagnostic(transparent)]
Forest(#[from] MastForestError),
}

Expand Down
4 changes: 0 additions & 4 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ std = [
math = { package = "winter-math", version = "0.9", default-features = false }
miden-crypto = { git = "https://github.com/0xPolygonMiden/crypto", branch = "next", default-features = false }
miden-formatting = { version = "0.1", default-features = false }
miette = { version = "7.1.0", git = "https://github.com/bitwalker/miette", branch = "no-std", default-features = false, features = [
"fancy-no-syscall",
"derive",
] }
num-derive = { version = "0.4", default-features = false }
num-traits = { version = "0.2", default-features = false }
thiserror = { version = "1.0", git = "https://github.com/bitwalker/thiserror", branch = "no-std", default-features = false }
Expand Down
3 changes: 1 addition & 2 deletions core/src/mast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use core::{fmt, ops::Index};

use alloc::vec::Vec;
use miden_crypto::hash::rpo::RpoDigest;
use miette::Diagnostic;

mod node;
pub use node::{
Expand Down Expand Up @@ -79,7 +78,7 @@ impl Deserializable for MastNodeId {
// ================================================================================================

/// Represents the types of errors that can occur when dealing with MAST forest.
#[derive(Debug, thiserror::Error, Diagnostic)]
#[derive(Debug, thiserror::Error)]
pub enum MastForestError {
#[error(
"invalid node count: MAST forest exceeds the maximum of {} nodes",
Expand Down

0 comments on commit dfab88f

Please sign in to comment.