diff --git a/src/context.rs b/src/context.rs index 326a1d4..d3761ff 100644 --- a/src/context.rs +++ b/src/context.rs @@ -142,10 +142,7 @@ impl<'a, T: ArenaObj> Ptr { impl Clone for Ptr { fn clone(&self) -> Ptr { - Ptr { - idx: self.idx, - _dummy: PhantomData, - } + *self } } diff --git a/src/dialects/builtin/ops.rs b/src/dialects/builtin/ops.rs index 6273fec..229a5b5 100644 --- a/src/dialects/builtin/ops.rs +++ b/src/dialects/builtin/ops.rs @@ -254,11 +254,7 @@ impl Printable for ConstantOp { write!( f, "{} = {} {}", - self.get_operation() - .deref(ctx) - .get_result(0) - .unwrap() - .get_name(ctx), + self.get_result(ctx).get_name(ctx), self.get_opid().disp(ctx), self.get_value(ctx).disp(ctx) ) @@ -274,7 +270,7 @@ impl Verify for ConstantOp { }); } let op = &*self.get_operation().deref(ctx); - if op.get_num_results() != 1 || op.get_num_operands() != 0 { + if op.get_num_operands() != 0 { return Err(CompilerError::VerificationError { msg: "Incorrect number of results or operands".to_string(), }); diff --git a/src/printable.rs b/src/printable.rs index 999819d..1370365 100644 --- a/src/printable.rs +++ b/src/printable.rs @@ -125,6 +125,10 @@ impl<'t, 'c, T: Printable> Display for Displayable<'t, 'c, T> { /// assert!(S { i: 0 }.print(&ctx, &state).to_string() == "0"); /// let svec = vec![ S { i: 8 }, S { i: 16 } ]; /// assert!(svec.iter().idisp(&ctx, ListSeparator::Char(',')).to_string() == "8,16"); +/// use pliron::{indented_block, printable::indented_nl}; +/// indented_block!(state, { +/// assert_eq!(format!("{}{}", indented_nl(&state), S { i: 108 }.print(&ctx, &state)), "\n 108"); +/// }); /// ``` pub trait Printable { fn fmt(&self, ctx: &Context, state: &State, f: &mut fmt::Formatter<'_>) -> fmt::Result;