diff --git a/src/melior_macro/dialect/generation/operation_builder.rs.html b/src/melior_macro/dialect/generation/operation_builder.rs.html index 8f91f6f3aa..d9dfbf3838 100644 --- a/src/melior_macro/dialect/generation/operation_builder.rs.html +++ b/src/melior_macro/dialect/generation/operation_builder.rs.html @@ -164,31 +164,6 @@ 163 164 165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190
use crate::dialect::{
     error::Error, operation::OperationBuilder, utility::sanitize_snake_case_identifier,
 };
@@ -196,43 +171,21 @@
 use quote::{format_ident, quote};
 
 pub fn generate_operation_builder(builder: &OperationBuilder) -> Result<TokenStream, Error> {
-    let field_names = builder
-        .type_state()
-        .field_names()
-        .map(sanitize_snake_case_identifier)
-        .collect::<Result<Vec<_>, _>>()?;
-
-    let phantom_fields =
-        builder
-            .type_state()
-            .parameters()
-            .zip(&field_names)
-            .map(|(r#type, name)| {
-                quote! {
-                    #name: ::std::marker::PhantomData<#r#type>
-                }
-            });
-
-    let phantom_arguments = field_names
-        .iter()
-        .map(|name| quote! { #name: Default::default() })
-        .collect::<Vec<_>>();
-
-    let field_fns = generate_field_fns(builder, &phantom_arguments);
-
-    let new_fn = generate_new_fn(builder, &phantom_arguments)?;
+    let state_types = builder.type_state().parameters();
+    let field_fns = generate_field_fns(builder);
+    let new_fn = generate_new_fn(builder)?;
     let build_fn = generate_build_fn(builder)?;
 
-    let builder_identifier = builder.identifier();
+    let identifier = builder.identifier();
     let doc = format!("A builder for {}", builder.operation().summary()?);
     let type_arguments = builder.type_state().parameters();
 
     Ok(quote! {
         #[doc = #doc]
-        pub struct #builder_identifier<'c, #(#type_arguments),*> {
+        pub struct #identifier<'c, #(#type_arguments),*> {
             builder: ::melior::ir::operation::OperationBuilder<'c>,
             context: &'c ::melior::Context,
-            #(#phantom_fields),*
+            _state: ::std::marker::PhantomData<(#(#state_types),*)>,
         }
 
         #new_fn
@@ -244,7 +197,7 @@
 }
 
 // TODO Split this function for different kinds of fields.
-fn generate_field_fns(builder: &OperationBuilder, phantoms: &[TokenStream]) -> Vec<TokenStream> {
+fn generate_field_fns(builder: &OperationBuilder) -> Vec<TokenStream> {
     builder.operation().fields().map(move |field| {
         let builder_identifier = builder.identifier();
         let identifier = field.singular_identifier();
@@ -281,7 +234,7 @@
                         #builder_identifier {
                             context: self.context,
                             builder: self.builder.#add(#add_arguments),
-                            #(#phantoms),*
+                            _state: Default::default(),
                         }
                     }
                 }
@@ -309,10 +262,7 @@
     })
 }
 
-fn generate_new_fn(
-    builder: &OperationBuilder,
-    phantoms: &[TokenStream],
-) -> Result<TokenStream, Error> {
+fn generate_new_fn(builder: &OperationBuilder) -> Result<TokenStream, Error> {
     let builder_ident = builder.identifier();
     let name = &builder.operation().full_name()?;
     let arguments = builder.type_state().arguments_all_set(false);
@@ -323,7 +273,7 @@
                 Self {
                     context,
                     builder: ::melior::ir::operation::OperationBuilder::new( #name, location),
-                    #(#phantoms),*
+                    _state: Default::default(),
                 }
             }
         }
diff --git a/src/melior_macro/dialect/operation/builder/type_state_list.rs.html b/src/melior_macro/dialect/operation/builder/type_state_list.rs.html
index 83e2ee957d..f673d5e0b3 100644
--- a/src/melior_macro/dialect/operation/builder/type_state_list.rs.html
+++ b/src/melior_macro/dialect/operation/builder/type_state_list.rs.html
@@ -60,10 +60,6 @@
 59
 60
 61
-62
-63
-64
-65
 
use super::type_state_item::TypeStateItem;
 use quote::quote;
 use std::iter::repeat;
@@ -85,10 +81,6 @@
         }
     }
 
-    pub fn field_names(&self) -> impl Iterator<Item = &str> {
-        self.items.iter().map(|item| item.field_name())
-    }
-
     pub fn parameters(&self) -> impl Iterator<Item = &GenericArgument> {
         self.items.iter().map(|item| item.generic_param())
     }