Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vaivaswatha committed Aug 29, 2023
1 parent 7552d94 commit b3431a0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
5 changes: 1 addition & 4 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,7 @@ impl<'a, T: ArenaObj> Ptr<T> {

impl<T: ArenaObj> Clone for Ptr<T> {
fn clone(&self) -> Ptr<T> {
Ptr {
idx: self.idx,
_dummy: PhantomData,
}
*self
}
}

Expand Down
8 changes: 2 additions & 6 deletions src/dialects/builtin/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand All @@ -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(),
});
Expand Down
4 changes: 4 additions & 0 deletions src/printable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b3431a0

Please sign in to comment.