Skip to content

Commit

Permalink
empty structs need not have () or {}
Browse files Browse the repository at this point in the history
  • Loading branch information
vaivaswatha committed Aug 10, 2024
1 parent a5c3cd4 commit 3c6a942
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions pliron-derive/src/derive_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ mod tests {
let args = quote! { "testing.unit" };
let input = quote! {
#[derive(PartialEq, Eq, Debug, Clone)]
pub struct UnitAttr();
pub struct UnitAttr;
};
let attr = def_attribute(args, input).unwrap();
let f = syn::parse2::<syn::File>(attr).unwrap();
Expand All @@ -145,7 +145,7 @@ mod tests {
#[derive(PartialEq, Eq, Debug, Clone)]
#[derive(::pliron_derive::DeriveAttribAcceptor)]
#[ir_kind = "attribute"]
pub struct UnitAttr();
pub struct UnitAttr;
impl ::pliron::attribute::Attribute for UnitAttr {
fn eq_attr(&self, other: &dyn ::pliron::attribute::Attribute) -> bool {
other.downcast_ref::<Self>().map_or(false, |other| other == self)
Expand Down
4 changes: 2 additions & 2 deletions pliron-derive/src/derive_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ mod tests {
let args = quote! { "testing.simple_type" };
let input = quote! {
#[derive(Hash, PartialEq, Eq, Debug)]
pub struct SimpleType {}
pub struct SimpleType;
};
let t = def_type(args, input).unwrap();
let f = syn::parse2::<syn::File>(t).unwrap();
Expand All @@ -146,7 +146,7 @@ mod tests {
#[derive(Hash, PartialEq, Eq, Debug)]
#[derive(::pliron_derive::DeriveAttribAcceptor)]
#[ir_kind = "type"]
pub struct SimpleType {}
pub struct SimpleType;
impl ::pliron::r#type::Type for SimpleType {
fn hash_type(&self) -> ::pliron::storage_uniquer::TypeValueHash {
::pliron::storage_uniquer::TypeValueHash::new(self)
Expand Down
4 changes: 2 additions & 2 deletions pliron-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub fn def_attribute(args: TokenStream, input: TokenStream) -> TokenStream {
/// ```ignore
/// #[def_type("my_dialect.unit")]
/// #[derive(Debug, Clone, PartialEq, Eq, Hash)]
/// pub struct UnitType();
/// pub struct UnitType;
/// ```
///
/// **Note**: pre-requisite traits for `Type` must already be implemented.
Expand All @@ -78,7 +78,7 @@ pub fn def_type(args: TokenStream, input: TokenStream) -> TokenStream {
///
/// ```ignore
/// #[def_op("my_dialect.op")]
/// pub struct MyOp {}
/// pub struct MyOp;
/// ```
///
/// The example will create a struct definition equivalent to:
Expand Down
26 changes: 13 additions & 13 deletions pliron-llvm/src/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use super::{
/// |-----|-------|
/// | `arg` | any type |
#[def_op("llvm.return")]
pub struct ReturnOp {}
pub struct ReturnOp;
impl ReturnOp {
/// Create a new [ReturnOp]
pub fn new(ctx: &mut Context, value: Option<Value>) -> Self {
Expand Down Expand Up @@ -98,7 +98,7 @@ macro_rules! new_int_bin_op {
/// | result | description |
/// |-----|-------|
/// | `res` | Signless integer |
pub struct $op_name {}
pub struct $op_name;

impl_verify_succ!($op_name);
impl_canonical_syntax!($op_name);
Expand Down Expand Up @@ -234,7 +234,7 @@ pub enum ICmpOpVerifyErr {
/// |-----|-------| --------------|
/// | [ATTR_KEY_PREDICATE](icmp_op::ATTR_KEY_PREDICATE) | [ICmpPredicateAttr](ICmpPredicateAttr) | N/A |
#[def_op("llvm.icmp")]
pub struct ICmpOp {}
pub struct ICmpOp;

pub mod icmp_op {
use std::sync::LazyLock;
Expand Down Expand Up @@ -335,7 +335,7 @@ pub enum AllocaOpVerifyErr {
/// |-----|-------| --------------|
/// | [ATTR_KEY_ELEM_TYPE](alloca_op::ATTR_KEY_ELEM_TYPE) | [TypeAttr](pliron::builtin::attributes::TypeAttr) | N/A |
#[def_op("llvm.alloca")]
pub struct AllocaOp {}
pub struct AllocaOp;
impl_canonical_syntax!(AllocaOp);
impl Verify for AllocaOp {
fn verify(&self, ctx: &Context) -> Result<()> {
Expand Down Expand Up @@ -410,7 +410,7 @@ impl AllocaOp {
/// |-----|-------|
/// | `res` | non-aggregate LLVM type |
#[def_op("llvm.bitcast")]
pub struct BitcastOp {}
pub struct BitcastOp;
impl_canonical_syntax!(BitcastOp);
impl_verify_succ!(BitcastOp);
impl_op_interface!(OneResultInterface for BitcastOp {});
Expand Down Expand Up @@ -444,7 +444,7 @@ impl BitcastOp {
/// |-----|-------|
/// | `dest` | Any successor |
#[def_op("llvm.br")]
pub struct BrOp {}
pub struct BrOp;
impl_canonical_syntax!(BrOp);
impl_verify_succ!(BrOp);
impl_op_interface!(IsTerminatorInterface for BrOp {});
Expand Down Expand Up @@ -485,7 +485,7 @@ impl BrOp {
/// | `true_dest` | Any successor |
/// | `false_dest` | Any successor |
#[def_op("llvm.cond_br")]
pub struct CondBrOp {}
pub struct CondBrOp;
impl CondBrOp {
/// Create anew [CondBrOp].
pub fn new(
Expand Down Expand Up @@ -568,7 +568,7 @@ pub enum GetElementPtrOpErr {
/// |-----|-------|
/// | `res` | LLVM pointer type |
#[def_op("llvm.gep")]
pub struct GetElementPtrOp {}
pub struct GetElementPtrOp;
impl_canonical_syntax!(GetElementPtrOp);
impl_op_interface!(OneResultInterface for GetElementPtrOp {});
impl_op_interface!(PointerTypeResult for GetElementPtrOp {
Expand Down Expand Up @@ -730,7 +730,7 @@ pub enum LoadOpVerifyErr {
/// ### Attributes:
///
#[def_op("llvm.load")]
pub struct LoadOp {}
pub struct LoadOp;
impl LoadOp {
/// Create a new [LoadOp]
pub fn new(ctx: &mut Context, ptr: Value, res_ty: Ptr<TypeObj>) -> Self {
Expand Down Expand Up @@ -778,7 +778,7 @@ pub enum StoreOpVerifyErr {
/// ### Attributes:
///
#[def_op("llvm.store")]
pub struct StoreOp {}
pub struct StoreOp;
impl StoreOp {
/// Create a new [LoadOp]
pub fn new(ctx: &mut Context, value: Value, ptr: Value) -> Self {
Expand Down Expand Up @@ -848,7 +848,7 @@ impl_op_interface!(ZeroResultInterface for LoadOp {});
/// | [ATTR_KEY_CALLEE_TYPE](pliron::builtin::op_interfaces::ATTR_KEY_CALLEE_TYPE) | [TypeAttr] | [CallOpInterface] |
///
#[def_op("llvm.call")]
pub struct CallOp {}
pub struct CallOp;

pub mod call_op {
use std::sync::LazyLock;
Expand Down Expand Up @@ -930,7 +930,7 @@ impl_op_interface!(OneResultInterface for CallOp {});
/// |-----|-------|
/// | `result` | any type |
#[def_op("llvm.undef")]
pub struct UndefOp {}
pub struct UndefOp;
impl_canonical_syntax!(UndefOp);
impl_verify_succ!(UndefOp);
impl_op_interface!(OneResultInterface for UndefOp {});
Expand Down Expand Up @@ -965,7 +965,7 @@ impl UndefOp {
/// |-----|-------|
/// | `result` | any type |
#[def_op("llvm.constant")]
pub struct ConstantOp {}
pub struct ConstantOp;

pub mod constant_op {
use std::sync::LazyLock;
Expand Down
6 changes: 3 additions & 3 deletions src/builtin/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl_attr_interface!(TypedAttrInterface for IntegerAttr {

/// A dummy implementation until we have a good one.
#[derive(PartialEq, Clone, Debug)]
pub struct APFloat();
pub struct APFloat;

/// An attribute containing an floating point value.
/// Similar to MLIR's [FloatAttr](https://mlir.llvm.org/docs/Dialects/Builtin/#floatattr).
Expand Down Expand Up @@ -395,11 +395,11 @@ impl Parsable for VecAttr {
/// See [UnitAttr](https://mlir.llvm.org/docs/Dialects/Builtin/#unitattr) in MLIR.
#[def_attribute("builtin.unit")]
#[derive(PartialEq, Eq, Clone, Copy, Debug, Default)]
pub struct UnitAttr();
pub struct UnitAttr;

impl UnitAttr {
pub fn new() -> Self {
UnitAttr()
UnitAttr
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/builtin/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use super::{
/// |-----|-------|-----|
/// | [ATTR_KEY_SYM_NAME](super::op_interfaces::ATTR_KEY_SYM_NAME) | [IdentifierAttr](super::attributes::IdentifierAttr) | [SymbolOpInterface] |
#[def_op("builtin.module")]
pub struct ModuleOp {}
pub struct ModuleOp;

impl Printable for ModuleOp {
fn fmt(
Expand Down Expand Up @@ -136,7 +136,7 @@ impl_op_interface!(ZeroResultInterface for ModuleOp {});
/// | [ATTR_KEY_SYM_NAME](super::op_interfaces::ATTR_KEY_SYM_NAME) | [IdentifierAttr](super::attributes::IdentifierAttr) | [SymbolOpInterface] |
/// | [ATTR_KEY_FUNC_TYPE](func_op::ATTR_KEY_FUNC_TYPE) | [TypeAttr](super::attributes::TypeAttr) | N/A |
#[def_op("builtin.func")]
pub struct FuncOp {}
pub struct FuncOp;

pub mod func_op {
use std::sync::LazyLock;
Expand Down Expand Up @@ -293,7 +293,7 @@ impl_op_interface!(ZeroResultInterface for FuncOp {});
/// [UnrealizedConversionCastOp](https://mlir.llvm.org/docs/Dialects/Builtin/#builtinunrealized_conversion_cast-unrealizedconversioncastop)
/// for this purpose.
#[def_op("builtin.forward_ref")]
pub struct ForwardRefOp {}
pub struct ForwardRefOp;

impl Printable for ForwardRefOp {
fn fmt(
Expand Down
2 changes: 1 addition & 1 deletion src/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ pub fn canonical_syntax_parser<'a>(
/// use pliron_derive::def_op;
/// use pliron::{impl_canonical_syntax, impl_verify_succ};
/// #[def_op("dialect.name")]
/// pub struct MyOp {};
/// pub struct MyOp;
/// impl_canonical_syntax!(MyOp);
/// impl_verify_succ!(MyOp);
/// ```
Expand Down
2 changes: 1 addition & 1 deletion tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use pliron::{
use pliron_derive::def_op;

#[def_op("test.return")]
pub struct ReturnOp {}
pub struct ReturnOp;
impl ReturnOp {
pub fn new(ctx: &mut Context, value: Value) -> Self {
let op = Operation::new(ctx, Self::get_opid_static(), vec![], vec![value], vec![], 0);
Expand Down

0 comments on commit 3c6a942

Please sign in to comment.