Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

Renaming, avoid escaping known modules, Parameterise builder types

+237 -264
+52 -52
compiler-core/src/erlang.rs
··· 32 32 33 33 /// This is an open runtime error to which more fields can still be added. 34 34 #[must_use] 35 - struct RuntimeError { 35 + struct RuntimeError<Map, Call> { 36 36 /// This is the map that is going to be thrown by the `erlang:error` call. 37 - error_map: erlang_generation::Map, 37 + error_map: Map, 38 38 /// This is the call to `erlang:error` that will throw the error, with the 39 39 /// map as an argument. 40 - erlang_error_call: erlang_generation::Call, 40 + erlang_error_call: Call, 41 41 } 42 42 43 43 /// Represents all the different kind of runtime errors that Gleam can raise. ··· 154 154 /// 155 155 variable_names: im::HashMap<SrcSpan, EcoString>, 156 156 157 - /// This keeps track of the number of throwaway variables that have already 157 + /// This keeps track of the number of generated variables that have already 158 158 /// been generated in the current function. 159 159 /// For example if this is `2` it means we've already generated: 160 160 /// ··· 164 164 /// _value@2 165 165 /// ``` 166 166 /// 167 - /// We need this to make sure that every time we generate a new throwaway 167 + /// We need this to make sure that every time we generate a new generated 168 168 /// variable it has a unique name not shadowing anything else. 169 169 /// 170 - throwaway_variables: usize, 170 + generated_variables: usize, 171 171 172 172 /// This keeps track of all the names that are taken for the current 173 173 /// function and can't be used when defining new variables. ··· 488 488 module_generator, 489 489 taken_names: im::HashMap::new(), 490 490 variable_names: im::HashMap::new(), 491 - throwaway_variables: 0, 491 + generated_variables: 0, 492 492 } 493 493 } 494 494 ··· 562 562 /// The generated name is guaranteed to always be unique for the given 563 563 /// function. 564 564 /// 565 - fn new_throwaway_variable(&mut self) -> EcoString { 566 - let name = if self.throwaway_variables == 0 { 565 + fn new_generated_variable(&mut self) -> EcoString { 566 + let name = if self.generated_variables == 0 { 567 567 EcoString::from("_value") 568 568 } else { 569 - eco_format!("_value@{}", self.throwaway_variables) 569 + eco_format!("_value@{}", self.generated_variables) 570 570 }; 571 - self.throwaway_variables += 1; 571 + self.generated_variables += 1; 572 572 name 573 573 } 574 574 ··· 732 732 // If an argument is made of just underscores, then that would result 733 733 // in a syntax error in the generated Erlang, where the external 734 734 // function is called with a discard `io:format(_, _)`! 735 - // So in this case we use a throwaway name to make sure the external 735 + // So in this case we use a generated name to make sure the external 736 736 // function can be called correctly. 737 737 ArgNames::Discard { name, location } 738 738 | ArgNames::LabelledDiscard { ··· 741 741 .. 742 742 } if is_external => { 743 743 if name.chars().all(|char| char == '_') { 744 - self.new_throwaway_variable() 744 + self.new_generated_variable() 745 745 } else { 746 746 self.new_erlang_variable(name, *location) 747 747 } ··· 764 764 // We go over each statement one by one and produce the code they need. 765 765 for i in 0..statements.len() { 766 766 match statements.get(i).expect("statement in range") { 767 - Statement::Expression(expression) => self.expr(builder, expression), 768 - Statement::Use(use_) => self.expr(builder, &use_.call), 767 + Statement::Expression(expression) => self.expression(builder, expression), 768 + Statement::Use(use_) => self.expression(builder, &use_.call), 769 769 Statement::Assert(assert) => self.assert(builder, assert), 770 770 Statement::Assignment(assignment) => match &assignment.kind { 771 771 AssignmentKind::Let | AssignmentKind::Generated => { ··· 812 812 } 813 813 } 814 814 815 - fn expr<Output>( 815 + fn expression<Output>( 816 816 &mut self, 817 817 builder: &mut impl ErlangBuilder<Output>, 818 818 expression: &'a TypedExpr, ··· 858 858 left, 859 859 right, 860 860 .. 861 - } => self.bin_op(builder, operator, left, right), 861 + } => self.binary_operator(builder, operator, left, right), 862 862 863 863 // 864 864 // BitArrays, Lists, and Tuples. ··· 1091 1091 /// After you're done generating those additional fields remember you _must_ 1092 1092 /// call `end_runtime_error` before generating any other piece of code! 1093 1093 /// 1094 - fn start_runtime_error<Output>( 1094 + fn start_runtime_error<Output, Builder: ErlangBuilder<Output>>( 1095 1095 &mut self, 1096 - builder: &mut impl ErlangBuilder<Output>, 1096 + builder: &mut Builder, 1097 1097 error_kind: RuntimeErrorKind, 1098 1098 location: SrcSpan, 1099 1099 message: Option<&'a TypedExpr>, 1100 - ) -> RuntimeError { 1101 - let call = builder.start_remote_call(ErlangModuleName::new("erlang"), "error"); 1100 + ) -> RuntimeError<Builder::Map, Builder::Call> { 1101 + let call = builder.start_remote_call(ErlangModuleName::erlang(), "error"); 1102 1102 let map = builder.start_map(); 1103 1103 1104 1104 builder.map_field(); ··· 1146 1146 } 1147 1147 1148 1148 /// This closes an open runtime error. 1149 - fn end_runtime_error<Output>( 1149 + fn end_runtime_error<Output, Builder: ErlangBuilder<Output>>( 1150 1150 &self, 1151 - builder: &mut impl ErlangBuilder<Output>, 1152 - runtime_error: RuntimeError, 1151 + builder: &mut Builder, 1152 + runtime_error: RuntimeError<Builder::Map, Builder::Call>, 1153 1153 ) { 1154 1154 builder.end_map(runtime_error.error_map); 1155 1155 builder.end_call(runtime_error.erlang_error_call); ··· 1162 1162 ) { 1163 1163 if needs_begin_end_wrapping(expression) { 1164 1164 let block = builder.start_block(); 1165 - self.expr(builder, expression); 1165 + self.expression(builder, expression); 1166 1166 builder.end_block(block); 1167 1167 } else { 1168 - self.expr(builder, expression); 1168 + self.expression(builder, expression); 1169 1169 } 1170 1170 } 1171 1171 ··· 1232 1232 // end 1233 1233 // ``` 1234 1234 let clause = builder.start_case_clause(); 1235 - let matched_value_name = self.new_throwaway_variable(); 1235 + let matched_value_name = self.new_generated_variable(); 1236 1236 builder.match_pattern(); 1237 1237 let mut generator = PatternGenerator::new(self); 1238 1238 generator.pattern(builder, pattern); ··· 1246 1246 1247 1247 // This is the catch all branch to throw an error otherwise. 1248 1248 let clause = builder.start_case_clause(); 1249 - let value_name = self.new_throwaway_variable(); 1249 + let value_name = self.new_generated_variable(); 1250 1250 builder.variable_pattern(&value_name); 1251 1251 let clause = builder.end_clause_pattern(clause); 1252 1252 let clause = builder.end_clause_guards(clause); ··· 1355 1355 }, 1356 1356 ) 1357 1357 } else { 1358 - self.expr(builder, finally) 1358 + self.expression(builder, finally) 1359 1359 } 1360 1360 } 1361 1361 ··· 1413 1413 }; 1414 1414 1415 1415 // If the left or right hand side are not simple variables we'll 1416 - // need to first assign those to throwaway variables and keep 1416 + // need to first assign those to generated variables and keep 1417 1417 // track of those names. 1418 1418 let left = if !left.is_var() { 1419 - let name = self.new_throwaway_variable(); 1419 + let name = self.new_generated_variable(); 1420 1420 builder.match_operator(); 1421 1421 builder.variable_pattern(&name); 1422 1422 self.maybe_block_expr(builder, left); 1423 - AssertionExpression::from_throwaway_variable(name, left) 1423 + AssertionExpression::from_generated_variable(name, left) 1424 1424 } else { 1425 1425 AssertionExpression::from_expression(left) 1426 1426 }; 1427 1427 1428 1428 let right = if !right.is_var() { 1429 - let name = self.new_throwaway_variable(); 1429 + let name = self.new_generated_variable(); 1430 1430 builder.match_operator(); 1431 1431 builder.variable_pattern(&name); 1432 1432 self.maybe_block_expr(builder, right); 1433 - AssertionExpression::from_throwaway_variable(name, right) 1433 + AssertionExpression::from_generated_variable(name, right) 1434 1434 } else { 1435 1435 AssertionExpression::from_expression(right) 1436 1436 }; ··· 1479 1479 let mut call_arguments = Vec::with_capacity(arguments.len()); 1480 1480 for argument in arguments { 1481 1481 let argument = if !argument.value.is_var() { 1482 - let name = self.new_throwaway_variable(); 1482 + let name = self.new_generated_variable(); 1483 1483 builder.match_operator(); 1484 1484 builder.variable_pattern(&name); 1485 1485 self.maybe_block_expr(builder, &argument.value); 1486 - AssertionExpression::from_throwaway_variable(name, &argument.value) 1486 + AssertionExpression::from_generated_variable(name, &argument.value) 1487 1487 } else { 1488 1488 AssertionExpression::from_expression(&argument.value) 1489 1489 }; ··· 1904 1904 tuple: &'a TypedExpr, 1905 1905 index: u64, 1906 1906 ) { 1907 - let call = builder.start_remote_call(ErlangModuleName::new("erlang"), "element"); 1907 + let call = builder.start_remote_call(ErlangModuleName::erlang(), "element"); 1908 1908 builder.int((index + 1).into()); 1909 1909 self.maybe_block_expr(builder, tuple); 1910 1910 builder.end_call(call); ··· 2213 2213 if let TypedExpr::Block { statements, .. } = &clause.then { 2214 2214 self.statement_sequence(builder, statements); 2215 2215 } else { 2216 - self.expr(builder, &clause.then); 2216 + self.expression(builder, &clause.then); 2217 2217 } 2218 2218 builder.end_clause_body(clause_body); 2219 2219 } ··· 2487 2487 }); 2488 2488 } 2489 2489 2490 - fn bin_op<Output>( 2490 + fn binary_operator<Output>( 2491 2491 &mut self, 2492 2492 builder: &mut impl ErlangBuilder<Output>, 2493 2493 name: &'a BinOp, ··· 2548 2548 // We first have to evaluate the left hand side, and store its 2549 2549 // result in a variable to use later. 2550 2550 let left_name = if !is_left_hand_side_pure { 2551 - let left_name = self.new_throwaway_variable(); 2551 + let left_name = self.new_generated_variable(); 2552 2552 builder.match_operator(); 2553 2553 builder.variable_pattern(&left_name); 2554 2554 self.maybe_block_expr(builder, left); ··· 2577 2577 builder.end_clause_body(body); 2578 2578 2579 2579 // _value -> left / _value 2580 - let denominator = self.new_throwaway_variable(); 2580 + let denominator = self.new_generated_variable(); 2581 2581 let clause = builder.start_case_clause(); 2582 2582 builder.variable_pattern(&denominator); 2583 2583 let guards = builder.end_clause_pattern(clause); ··· 2624 2624 } => { 2625 2625 // If the left hand side is not a pure expression we will have 2626 2626 // to evaluate it before the right hand side of the expression. 2627 - // So we assign it to a throwaway variable that we will then 2627 + // So we assign it to a generated variable that we will then 2628 2628 // reference in the case expression's body. 2629 2629 // It will look something like this: 2630 2630 // ··· 2637 2637 // ``` 2638 2638 // 2639 2639 let left_name = if !is_left_hand_side_pure { 2640 - let left_name = self.new_throwaway_variable(); 2640 + let left_name = self.new_generated_variable(); 2641 2641 builder.match_operator(); 2642 2642 builder.variable_pattern(&left_name); 2643 2643 self.maybe_block_expr(builder, left); ··· 2658 2658 builder.end_clause_body(body); 2659 2659 2660 2660 // _value -> left div _value 2661 - let denominator = self.new_throwaway_variable(); 2661 + let denominator = self.new_generated_variable(); 2662 2662 let clause = builder.start_case_clause(); 2663 2663 builder.variable_pattern(&denominator); 2664 2664 let guards = builder.end_clause_pattern(clause); ··· 2763 2763 // unicode:characters_to_binary(<segment_value>, utf8, {utf16, big}) 2764 2764 // ``` 2765 2765 let call = 2766 - builder.start_remote_call(ErlangModuleName::new("unicode"), "characters_to_binary"); 2766 + builder.start_remote_call(ErlangModuleName::unicode(), "characters_to_binary"); 2767 2767 { 2768 2768 self.maybe_block_expr(builder, &segment.value); 2769 2769 builder.atom("utf8"); ··· 2814 2814 builder.int(int_value.clone()); 2815 2815 } 2816 2816 } else { 2817 - let call = builder.start_remote_call(ErlangModuleName::new("erlang"), "max"); 2817 + let call = builder.start_remote_call(ErlangModuleName::erlang(), "max"); 2818 2818 builder.int(BigInt::ZERO); 2819 2819 self.maybe_block_expr(builder, size); 2820 2820 builder.end_call(call); ··· 2916 2916 tuple: &'a TypedClauseGuard, 2917 2917 index: u64, 2918 2918 ) { 2919 - let call = builder.start_remote_call(ErlangModuleName::new("erlang"), "element"); 2919 + let call = builder.start_remote_call(ErlangModuleName::erlang(), "element"); 2920 2920 builder.int((index + 1).into()); 2921 2921 self.clause_guard(builder, tuple, &HashMap::new()); 2922 2922 builder.end_call(call); ··· 2989 2989 arguments: usize, 2990 2990 ) { 2991 2991 let arguments = (0..arguments) 2992 - .map(|_| self.new_throwaway_variable()) 2992 + .map(|_| self.new_generated_variable()) 2993 2993 .collect_vec(); 2994 2994 let function = builder.start_anonymous_function(&arguments); 2995 2995 ··· 3265 3265 pub fn record_definition(record_name: &str, fields: &[(&str, Arc<Type>)]) -> String { 3266 3266 let mut builder = ErlangSourceBuilder::new(None); 3267 3267 3268 - let record = builder.start_record_attribute(&to_snake_case(record_name)); 3268 + builder.start_record_attribute(&to_snake_case(record_name)); 3269 3269 3270 3270 let type_printer = TypeGenerator::new("").var_as_any(); 3271 3271 for (field_name, field_type) in fields { ··· 3274 3274 type_printer.type_(&mut builder, field_type); 3275 3275 } 3276 3276 3277 - builder.end_record_attribute(record); 3277 + builder.end_record_attribute(()); 3278 3278 builder.into_output() 3279 3279 } 3280 3280 ··· 3563 3563 self 3564 3564 } 3565 3565 3566 - fn from_throwaway_variable(name: EcoString, original_expression: &'a TypedExpr) -> Self { 3566 + fn from_generated_variable(name: EcoString, original_expression: &'a TypedExpr) -> Self { 3567 3567 Self { 3568 3568 runtime_value: Some(AssertedExpressionRuntimeValue::Variable(name)), 3569 3569 kind: if original_expression.is_literal() { ··· 3628 3628 /// That's because we know wether the assertion failed (it must be false), 3629 3629 /// or not (it must be true). 3630 3630 KnownBool(bool), 3631 - /// The asserted value was bound to a throwaway variable with the given 3631 + /// The asserted value was bound to a generated variable with the given 3632 3632 /// name, and we can reference it using that name. 3633 3633 Variable(EcoString), 3634 3634 /// The asserted value is an expression we need to inline in the error.
+1 -1
compiler-core/src/erlang/pattern.rs
··· 415 415 builder.end_clause_body(clause); 416 416 417 417 let clause = builder.start_case_clause(); 418 - let denominator = self.generator.new_throwaway_variable(); 418 + let denominator = self.generator.new_generated_variable(); 419 419 builder.variable_pattern(&denominator); 420 420 let clause = builder.end_clause_pattern(clause); 421 421 let clause = builder.end_clause_guards(clause);
+184 -211
erlang-generation/src/lib.rs
··· 35 35 pub fn new(gleam_module_name: &str) -> Self { 36 36 Self(gleam_module_name.replace("/", "@").into()) 37 37 } 38 - } 39 38 40 - #[must_use] 41 - /// Represents an open function that has yet to be closed. 42 - /// A function definition is started with `ErlangBuilder::start_function` and 43 - /// _must_ be closed using `ErlangBuilder::end_function`. 44 - pub struct Function {} 45 - 46 - #[must_use] 47 - /// Represents an open function call that has yet to be closed. 48 - pub struct Call {} 49 - 50 - #[must_use] 51 - /// Represents an open case expression that has yet to be closed. 52 - pub struct Case {} 53 - 54 - #[must_use] 55 - /// Represents an open case clause pattern that has yet to be generated. 56 - pub struct ClausePattern {} 57 - 58 - #[must_use] 59 - /// Represents a set of clause guards that has yet to be closed. 60 - pub struct ClauseGuards {} 61 - 62 - #[must_use] 63 - /// Represents an open clause body that has yet to be closed. 64 - pub struct ClauseBody {} 39 + /// The Erlang/OTP `erlang` module. 40 + pub fn erlang() -> Self { 41 + Self("erlang".into()) 42 + } 65 43 66 - #[must_use] 67 - /// Represents an open tuple that has yet to be closed. 68 - pub struct Tuple {} 69 - 70 - #[must_use] 71 - /// Represents an open map that has yet to be closed. 72 - pub struct Map {} 73 - 74 - #[must_use] 75 - /// Represents an open bit array that has yet to be closed. 76 - pub struct BitArray {} 77 - 78 - #[must_use] 79 - /// Represents an open bit array pattern that has yet to be closed. 80 - pub struct BitArrayPattern {} 81 - 82 - #[must_use] 83 - /// Represents an open tuple type that has yet to be closed. 84 - pub struct TupleType {} 85 - 86 - #[must_use] 87 - /// Represents an open tuple pattern that has yet to be closed. 88 - pub struct TuplePattern {} 89 - 90 - #[must_use] 91 - /// Represents an open doc/moduledoc attribute. 92 - pub struct DocAttribute {} 93 - 94 - #[must_use] 95 - /// Represents an open record attribute. 96 - pub struct RecordAttribute {} 97 - 98 - #[must_use] 99 - /// Represents an open function type annotation that has yet to be closed after 100 - /// generating the arguments types and the return type. 101 - pub struct FunctionType {} 102 - 103 - #[must_use] 104 - /// Represents an open named type that has yet to be closed after generating 105 - /// the types it takes as an argument (if any). 106 - pub struct NamedType {} 107 - 108 - #[must_use] 109 - /// Represents an open alternative type that has yet to be closed after 110 - /// generating all of its alternatives. 111 - pub struct UnionType {} 112 - 113 - #[must_use] 114 - /// Represents an open function type annotation that has yet to be closed after 115 - /// generating the arguments types and the return type. 116 - pub struct FunctionSpec {} 117 - 118 - #[must_use] 119 - /// Represents an open block that has yet to be closed after generating the 120 - /// statements that go inside it. 121 - pub struct Block {} 122 - 123 - #[must_use] 124 - /// Represents an open list of arguments' types in a function type annotation 125 - /// that has yet to be closed. 126 - pub struct FunctionTypeArguments {} 44 + /// The Erlang/OTP `unicode` module. 45 + pub fn unicode() -> Self { 46 + Self("unicode".into()) 47 + } 48 + } 127 49 128 50 /// All the possible specifiers that can be used in a bit array segment. 129 51 pub enum BitArraySegmentSpecifier { ··· 157 79 /// https://www.erlang.org/doc/apps/erts/absform.html 158 80 /// 159 81 pub trait ErlangBuilder<Output> { 82 + /// Represents an open function that has yet to be closed. 83 + /// A function definition is started with `ErlangBuilder::start_function` and 84 + /// _must_ be closed using `ErlangBuilder::end_function`. 85 + type Function; 86 + 87 + /// Represents an open function call that has yet to be closed. 88 + type Call; 89 + 90 + /// Represents an open case expression that has yet to be closed. 91 + type Case; 92 + 93 + /// Represents an open case clause pattern that has yet to be generated. 94 + type ClausePattern; 95 + 96 + /// Represents a set of clause guards that has yet to be closed. 97 + type ClauseGuards; 98 + 99 + /// Represents an open clause body that has yet to be closed. 100 + type ClauseBody; 101 + 102 + /// Represents an open tuple that has yet to be closed. 103 + type Tuple; 104 + 105 + /// Represents an open map that has yet to be closed. 106 + type Map; 107 + 108 + /// Represents an open bit array that has yet to be closed. 109 + type BitArray; 110 + 111 + /// Represents an open bit array pattern that has yet to be closed. 112 + type BitArrayPattern; 113 + 114 + /// Represents an open tuple type that has yet to be closed. 115 + type TupleType; 116 + 117 + /// Represents an open tuple pattern that has yet to be closed. 118 + type TuplePattern; 119 + 120 + /// Represents an open doc/moduledoc attribute. 121 + type DocAttribute; 122 + 123 + /// Represents an open record attribute. 124 + type RecordAttribute; 125 + 126 + /// Represents an open function type annotation that has yet to be closed after 127 + /// generating the arguments types and the return type. 128 + type FunctionType; 129 + 130 + /// Represents an open named type that has yet to be closed after generating 131 + /// the types it takes as an argument (if any). 132 + type NamedType; 133 + 134 + /// Represents an open alternative type that has yet to be closed after 135 + /// generating all of its alternatives. 136 + type UnionType; 137 + 138 + /// Represents an open function type annotation that has yet to be closed after 139 + /// generating the arguments types and the return type. 140 + type FunctionSpec; 141 + 142 + /// Represents an open block that has yet to be closed after generating the 143 + /// statements that go inside it. 144 + type Block; 145 + 146 + /// Represents an open list of arguments' types in a function type annotation 147 + /// that has yet to be closed. 148 + type FunctionTypeArguments; 149 + 160 150 /// Creates a new `ErlangBuilder` data structure to generate Erlang code. 161 151 /// If a module name is provided this will also automatically take care of 162 152 /// generating the appropriate `-module` annotation at the very beginning. ··· 230 220 /// -doc(false). 231 221 /// ``` 232 222 /// 233 - fn start_doc_attribute(&mut self) -> DocAttribute; 223 + fn start_doc_attribute(&mut self) -> Self::DocAttribute; 234 224 235 225 /// Starts a `-moduledoc` attribute. 236 226 /// What is generated after calling this function will end up inside the ··· 251 241 /// -moduledoc(false). 252 242 /// ``` 253 243 /// 254 - fn start_moduledoc_attribute(&mut self) -> DocAttribute; 244 + fn start_moduledoc_attribute(&mut self) -> Self::DocAttribute; 255 245 256 246 /// This closes the currently open doc/moduledoc attribute. 257 247 /// Code generated after this is not gonna be part of it. 258 248 /// 259 - fn end_doc_attribute(&mut self, attribute: DocAttribute); 249 + fn end_doc_attribute(&mut self, attribute: Self::DocAttribute); 260 250 261 251 /// This generates the code for a `-compile([]).` attribute where all the 262 252 /// strings produces by the given iterator are going to be passed as atom ··· 311 301 /// -record(wobble, { wibble :: ok }). 312 302 /// ``` 313 303 /// 314 - fn start_record_attribute(&mut self, record_name: &str) -> RecordAttribute; 304 + fn start_record_attribute(&mut self, record_name: &str) -> Self::RecordAttribute; 315 305 316 306 /// This closes the currently open record attribute. 317 307 /// Code generated after this is not gonna be part of it. 318 308 /// 319 - fn end_record_attribute(&mut self, record: RecordAttribute); 309 + fn end_record_attribute(&mut self, record: Self::RecordAttribute); 320 310 321 311 /// This creates a record field inside a record attribute. 322 312 /// After this you're supposed to generate two things: ··· 351 341 /// -spec wibble(integer(), A) -> A. 352 342 /// ``` 353 343 /// 354 - fn start_function_spec(&mut self, name: &str, arity: usize) -> FunctionSpec; 344 + fn start_function_spec(&mut self, name: &str, arity: usize) -> Self::FunctionSpec; 355 345 356 346 /// This closes the currently open function spec. 357 347 /// Code generated after this is not gonna be part of this function spec. 358 348 /// 359 - fn end_function_spec(&mut self, function_spec: FunctionSpec); 349 + fn end_function_spec(&mut self, function_spec: Self::FunctionSpec); 360 350 361 351 /// This starts an Erlang type spec. 362 352 /// After this call you're expected to generate a single type; that's going ··· 413 403 /// (integer(), A) -> A. 414 404 /// ``` 415 405 /// 416 - fn start_function_type(&mut self) -> FunctionTypeArguments; 406 + fn start_function_type(&mut self) -> Self::FunctionTypeArguments; 417 407 418 408 /// This closes the currently open function type arguments list. 419 409 /// This means that the next type that is generated is going to be the ··· 422 412 /// After that you must call `end_function_type` to close the function 423 413 /// type. 424 414 /// 425 - fn end_function_type_arguments(&mut self, function_type: FunctionTypeArguments) 426 - -> FunctionType; 415 + fn end_function_type_arguments( 416 + &mut self, 417 + function_type: Self::FunctionTypeArguments, 418 + ) -> Self::FunctionType; 427 419 428 420 /// This takes a function type and closes it. 429 421 /// Code generated after this is not gonna be part of this function type. 430 422 /// 431 - fn end_function_type(&mut self, function_type: FunctionType); 423 + fn end_function_type(&mut self, function_type: Self::FunctionType); 432 424 433 425 /// This starts a named type (either defined previously in this module, or 434 426 /// a built-in Erlang type) with the given name. ··· 448 440 /// wibble(). 449 441 /// ``` 450 442 /// 451 - fn start_named_type(&mut self, name: &str) -> NamedType; 443 + fn start_named_type(&mut self, name: &str) -> Self::NamedType; 452 444 453 445 /// This starts a remote named type with the given module and name. 454 446 /// Any code generated after this is gonna be an argument of the open ··· 467 459 /// wibble:wobble(). 468 460 /// ``` 469 461 /// 470 - fn start_remote_named_type(&mut self, module: ErlangModuleName, name: &str) -> NamedType; 462 + fn start_remote_named_type(&mut self, module: ErlangModuleName, name: &str) -> Self::NamedType; 471 463 472 464 /// This takes a named type and closes it. 473 465 /// Code generated after this is not gonna be part of this named type. 474 466 /// 475 - fn end_named_type(&mut self, named_type: NamedType); 467 + fn end_named_type(&mut self, named_type: Self::NamedType); 476 468 477 469 /// This starts a tuple type. 478 470 /// Any code generated after this is gonna be one of the tuple items. ··· 492 484 /// {nil, ok}. 493 485 /// ``` 494 486 /// 495 - fn start_tuple_type(&mut self) -> TupleType; 487 + fn start_tuple_type(&mut self) -> Self::TupleType; 496 488 497 489 /// This takes a tuple type and closes it. 498 490 /// Code generated after this is not gonna be part of this tuple type. 499 491 /// 500 - fn end_tuple_type(&mut self, tuple: TupleType); 492 + fn end_tuple_type(&mut self, tuple: Self::TupleType); 501 493 502 494 /// This starts a union type. 503 495 /// Any code generated after this is gonna be a possible alternative of this ··· 518 510 /// ok | error. 519 511 /// ``` 520 512 /// 521 - fn start_union_type(&mut self) -> UnionType; 513 + fn start_union_type(&mut self) -> Self::UnionType; 522 514 523 515 /// This takes a union type and closes it. 524 516 /// Code generated after this is not gonna be part of this union type. 525 517 /// 526 - fn end_union_type(&mut self, union_type: UnionType); 518 + fn end_union_type(&mut self, union_type: Self::UnionType); 527 519 528 520 /// This generated the code for a type variable with the given name. 529 521 /// ··· 591 583 name: &str, 592 584 arity: usize, 593 585 arguments_names: impl IntoIterator<Item = Name>, 594 - ) -> Function; 586 + ) -> Self::Function; 595 587 596 588 /// This starts an expression defining an anonymous function. 597 589 /// Any code generated after this is gonna be a statement inside the ··· 614 606 fn start_anonymous_function<Name: AsRef<str>>( 615 607 &mut self, 616 608 arguments_names: impl IntoIterator<Item = Name>, 617 - ) -> Function; 609 + ) -> Self::Function; 618 610 619 611 /// This takes a function and closes it. 620 612 /// Code generated after this is not gonna be part of this function. 621 613 /// 622 - fn end_function(&mut self, function: Function); 614 + fn end_function(&mut self, function: Self::Function); 623 615 624 616 /// This starts a block expression. 625 617 /// Any code generated after this is gonna be a statement inside the open ··· 643 635 /// end. 644 636 /// ``` 645 637 /// 646 - fn start_block(&mut self) -> Block; 638 + fn start_block(&mut self) -> Self::Block; 647 639 648 640 /// This takes a block and closes it. 649 641 /// Code generated after this is not gonna be part of this block. 650 642 /// 651 - fn end_block(&mut self, block: Block); 643 + fn end_block(&mut self, block: Self::Block); 652 644 653 645 /// This starts a remote call. 654 646 /// Any code generated after this is gonna be an argument of the open ··· 668 660 /// io:format(~"Giacomo"). 669 661 /// ``` 670 662 /// 671 - fn start_remote_call(&mut self, module: ErlangModuleName, function: &str) -> Call; 663 + fn start_remote_call(&mut self, module: ErlangModuleName, function: &str) -> Self::Call; 672 664 673 665 /// This starts a function call. 674 666 /// The expression generated immediately after this is going to be the thing ··· 690 682 /// wibble(~"Hello", ~"Giacomo"). 691 683 /// ``` 692 684 /// 693 - fn start_call(&mut self) -> Call; 685 + fn start_call(&mut self) -> Self::Call; 694 686 695 687 /// This takes an open call and closes it. 696 688 /// Code generated after this is not gonna be an argument to this call. 697 689 /// 698 - fn end_call(&mut self, call: Call); 690 + fn end_call(&mut self, call: Self::Call); 699 691 700 692 /// This starts a tuple. 701 693 /// Any code generated after this is gonna be an item of the tuple. ··· 715 707 /// {~"Hello", 1}. 716 708 /// ``` 717 709 /// 718 - fn start_tuple(&mut self) -> Tuple; 710 + fn start_tuple(&mut self) -> Self::Tuple; 719 711 720 712 /// This takes an open tuple and closes it. 721 713 /// Code generated after this is not gonna be an item of the tuple. 722 714 /// 723 - fn end_tuple(&mut self, tuple: Tuple); 715 + fn end_tuple(&mut self, tuple: Self::Tuple); 724 716 725 717 /// This starts an Erlang map. 726 718 /// After this call you can add fields to the map using the `map_field` ··· 749 741 /// }. 750 742 /// ``` 751 743 /// 752 - fn start_map(&mut self) -> Map; 744 + fn start_map(&mut self) -> Self::Map; 753 745 754 746 /// This takes an open map and closes it. 755 747 /// Code generated after this is not gonna be a map field. 756 748 /// 757 - fn end_map(&mut self, map: Map); 749 + fn end_map(&mut self, map: Self::Map); 758 750 759 751 /// This is used to add new fields to an open map. 760 752 /// After calling this you must generate exactly two values: the first one ··· 789 781 /// <<1, ~"hello">>. 790 782 /// ``` 791 783 /// 792 - fn start_bit_array(&mut self) -> BitArray; 784 + fn start_bit_array(&mut self) -> Self::BitArray; 793 785 794 786 /// This takes an open bit array and closes it. 795 787 /// Code generated after this is not gonna be a segment of the bit array. 796 788 /// 797 - fn end_bit_array(&mut self, bit_array: BitArray); 789 + fn end_bit_array(&mut self, bit_array: Self::BitArray); 798 790 799 791 /// This starts a new bit array segment. Make sure to call it after 800 792 /// `start_bit_array`! ··· 894 886 /// end. 895 887 /// ``` 896 888 /// 897 - fn start_case(&mut self) -> Case; 889 + fn start_case(&mut self) -> Self::Case; 898 890 899 891 /// This ends an open case expression. 900 892 /// Any code generated after this is not going to be part of it. 901 893 /// 902 - fn end_case(&mut self, case: Case); 894 + fn end_case(&mut self, case: Self::Case); 903 895 904 896 /// This starts a new case clause inside a case expression. 905 897 /// After this is called you must generate a single pattern and then call ··· 907 899 /// 908 900 /// For an example on how to generate a full case clause check the 909 901 /// `start_case` documentation. 910 - fn start_case_clause(&mut self) -> ClausePattern; 902 + fn start_case_clause(&mut self) -> Self::ClausePattern; 911 903 912 904 /// This ends the case clause's pattern. After this you must generate the 913 905 /// clause guards and then call `end_clause_guards`. 914 906 /// If the clause you're generating has no guards you can immediately call 915 907 /// that function without generating anything inbetween. 916 - fn end_clause_pattern(&mut self, clause_pattern: ClausePattern) -> ClauseGuards; 908 + fn end_clause_pattern(&mut self, clause_pattern: Self::ClausePattern) -> Self::ClauseGuards; 917 909 918 910 /// This ends the case clause's guards. Anything that is generated after 919 911 /// this is going to be a statement inside the current case clause until 920 912 /// `end_clause_body` is called. 921 - fn end_clause_guards(&mut self, clause_guards: ClauseGuards) -> ClauseBody; 913 + fn end_clause_guards(&mut self, clause_guards: Self::ClauseGuards) -> Self::ClauseBody; 922 914 923 915 /// This takes an open clause body and ends it. 924 916 /// After this you can start generating new case clauses, or end the 925 917 /// currently open case expression if this was the last clause! 926 - fn end_clause_body(&mut self, clause_body: ClauseBody); 918 + fn end_clause_body(&mut self, clause_body: Self::ClauseBody); 927 919 928 920 /// This creates a variable expression with the given name. 929 921 /// For example: ··· 1118 1110 /// {~"Hello", _}. 1119 1111 /// ``` 1120 1112 /// 1121 - fn start_tuple_pattern(&mut self) -> TuplePattern; 1113 + fn start_tuple_pattern(&mut self) -> Self::TuplePattern; 1122 1114 1123 1115 /// This takes an open tuple pattern and closes it. 1124 1116 /// Any code generated after this is not gonna be part of that pattern. 1125 - fn end_tuple_pattern(&mut self, tuple: TuplePattern); 1117 + fn end_tuple_pattern(&mut self, tuple: Self::TuplePattern); 1126 1118 1127 1119 /// This starts an Erlang bitstring (that's a Gleam's BitArray) pattern. 1128 1120 /// Any code generated after this is gonna be a segment of the pattern. ··· 1151 1143 /// <<1, _>>. 1152 1144 /// ``` 1153 1145 /// 1154 - fn start_bit_array_pattern(&mut self) -> BitArrayPattern; 1146 + fn start_bit_array_pattern(&mut self) -> Self::BitArrayPattern; 1155 1147 1156 1148 /// This takes an open bit array pattern and closes it. 1157 1149 /// Code generated after this is not gonna be a segment of the bit array. 1158 1150 /// 1159 - fn end_bit_array_pattern(&mut self, bit_array: BitArrayPattern); 1151 + fn end_bit_array_pattern(&mut self, bit_array: Self::BitArrayPattern); 1160 1152 1161 1153 /// This creates a list pattern. 1162 1154 /// The next two generated values are going to be respectively the pattern ··· 1691 1683 /// require a bit of extra book-keeping in the `new_x` functions. 1692 1684 /// 1693 1685 impl ErlangBuilder<String> for ErlangSourceBuilder { 1686 + type BitArray = (); 1687 + type BitArrayPattern = (); 1688 + type Block = (); 1689 + type Call = (); 1690 + type Case = (); 1691 + type ClauseBody = (); 1692 + type ClauseGuards = (); 1693 + type ClausePattern = (); 1694 + type DocAttribute = (); 1695 + type Function = (); 1696 + type FunctionSpec = (); 1697 + type FunctionType = (); 1698 + type FunctionTypeArguments = (); 1699 + type Map = (); 1700 + type NamedType = (); 1701 + type RecordAttribute = (); 1702 + type Tuple = (); 1703 + type TuplePattern = (); 1704 + type TupleType = (); 1705 + type UnionType = (); 1706 + 1694 1707 fn new(module: Option<ErlangModuleName>) -> Self { 1695 1708 Self { 1696 1709 code: if let Some(module) = module { ··· 1765 1778 self.code.push_str("]).\n"); 1766 1779 } 1767 1780 1768 - fn start_doc_attribute(&mut self) -> DocAttribute { 1781 + fn start_doc_attribute(&mut self) -> Self::DocAttribute { 1769 1782 self.new_top_level_form(); 1770 1783 self.code.push_str("-doc("); 1771 1784 self.position 1772 1785 .push(ErlangSourceBuilderPosition::DocAttribute); 1773 - DocAttribute {} 1774 1786 } 1775 1787 1776 - fn start_moduledoc_attribute(&mut self) -> DocAttribute { 1788 + fn start_moduledoc_attribute(&mut self) -> Self::DocAttribute { 1777 1789 self.new_top_level_form(); 1778 1790 self.code.push_str("-moduledoc("); 1779 1791 self.position 1780 1792 .push(ErlangSourceBuilderPosition::DocAttribute); 1781 - DocAttribute {} 1782 1793 } 1783 1794 1784 - fn end_doc_attribute(&mut self, _attribute: DocAttribute) { 1795 + fn end_doc_attribute(&mut self, _attribute: Self::DocAttribute) { 1785 1796 self.close_currently_open_item(); 1786 1797 } 1787 1798 ··· 1812 1823 self.code.push_str(")."); 1813 1824 } 1814 1825 1815 - fn start_record_attribute(&mut self, record_name: &str) -> RecordAttribute { 1826 + fn start_record_attribute(&mut self, record_name: &str) -> Self::RecordAttribute { 1816 1827 self.new_top_level_form(); 1817 1828 self.code.push_str("-record("); 1818 1829 self.code.push_str(&quote_atom_name(record_name)); ··· 1820 1831 self.indentation += INDENT; 1821 1832 self.position 1822 1833 .push(ErlangSourceBuilderPosition::RecordAttribute { first: true }); 1823 - 1824 - RecordAttribute {} 1825 1834 } 1826 1835 1827 - fn end_record_attribute(&mut self, _record: RecordAttribute) { 1836 + fn end_record_attribute(&mut self, _record: Self::RecordAttribute) { 1828 1837 self.close_currently_open_item(); 1829 1838 } 1830 1839 ··· 1836 1845 }); 1837 1846 } 1838 1847 1839 - fn start_function_spec(&mut self, name: &str, _arity: usize) -> FunctionSpec { 1848 + fn start_function_spec(&mut self, name: &str, _arity: usize) -> Self::FunctionSpec { 1840 1849 self.new_top_level_form(); 1841 1850 self.code.push_str("\n-spec "); 1842 1851 self.code.push_str(&quote_atom_name(name)); 1843 1852 self.position 1844 1853 .push(ErlangSourceBuilderPosition::FunctionSpec); 1845 - FunctionSpec {} 1846 1854 } 1847 1855 1848 - fn end_function_spec(&mut self, _function_spec: FunctionSpec) { 1856 + fn end_function_spec(&mut self, _function_spec: Self::FunctionSpec) { 1849 1857 self.close_currently_open_item(); 1850 1858 } 1851 1859 ··· 1877 1885 }); 1878 1886 } 1879 1887 1880 - fn start_function_type(&mut self) -> FunctionTypeArguments { 1888 + fn start_function_type(&mut self) -> Self::FunctionTypeArguments { 1881 1889 self.new_type(); 1882 1890 1883 1891 let needs_wrapping = ··· 1894 1902 expected: ExpectedFunctionTypeItem::Arguments { first: true }, 1895 1903 needs_wrapping, 1896 1904 }); 1897 - 1898 - FunctionTypeArguments {} 1899 1905 } 1900 1906 1901 1907 fn end_function_type_arguments( 1902 1908 &mut self, 1903 - _function_type: FunctionTypeArguments, 1904 - ) -> FunctionType { 1909 + _function_type: Self::FunctionTypeArguments, 1910 + ) -> Self::FunctionType { 1905 1911 self.close_currently_open_item(); 1906 - 1907 - FunctionType {} 1908 1912 } 1909 1913 1910 - fn end_function_type(&mut self, _function_type: FunctionType) { 1914 + fn end_function_type(&mut self, _function_type: Self::FunctionType) { 1911 1915 self.close_currently_open_item(); 1912 1916 } 1913 1917 1914 - fn start_named_type(&mut self, name: &str) -> NamedType { 1918 + fn start_named_type(&mut self, name: &str) -> Self::NamedType { 1915 1919 self.new_type(); 1916 1920 self.position 1917 1921 .push(ErlangSourceBuilderPosition::NamedType { first: true }); 1918 1922 self.code.push_str(&quote_atom_name(name)); 1919 1923 self.code.push('('); 1920 - 1921 - NamedType {} 1922 1924 } 1923 1925 1924 - fn start_remote_named_type(&mut self, module: ErlangModuleName, name: &str) -> NamedType { 1926 + fn start_remote_named_type(&mut self, module: ErlangModuleName, name: &str) -> Self::NamedType { 1925 1927 self.new_type(); 1926 1928 self.position 1927 1929 .push(ErlangSourceBuilderPosition::NamedType { first: true }); ··· 1929 1931 self.code.push(':'); 1930 1932 self.code.push_str(&quote_atom_name(name)); 1931 1933 self.code.push('('); 1932 - 1933 - NamedType {} 1934 1934 } 1935 1935 1936 - fn end_named_type(&mut self, _named_type: NamedType) { 1936 + fn end_named_type(&mut self, _named_type: Self::NamedType) { 1937 1937 self.close_currently_open_item(); 1938 1938 } 1939 1939 1940 - fn start_tuple_type(&mut self) -> TupleType { 1940 + fn start_tuple_type(&mut self) -> Self::TupleType { 1941 1941 self.new_type(); 1942 1942 self.position 1943 1943 .push(ErlangSourceBuilderPosition::TupleType { first: true }); 1944 1944 self.code.push('{'); 1945 - 1946 - TupleType {} 1947 1945 } 1948 1946 1949 - fn end_tuple_type(&mut self, _tuple: TupleType) { 1947 + fn end_tuple_type(&mut self, _tuple: Self::TupleType) { 1950 1948 self.close_currently_open_item(); 1951 1949 } 1952 1950 1953 - fn start_union_type(&mut self) -> UnionType { 1951 + fn start_union_type(&mut self) -> Self::UnionType { 1954 1952 self.new_type(); 1955 1953 self.position 1956 1954 .push(ErlangSourceBuilderPosition::UnionType { first: true }); 1957 - 1958 - UnionType {} 1959 1955 } 1960 1956 1961 - fn end_union_type(&mut self, _union_type: UnionType) { 1957 + fn end_union_type(&mut self, _union_type: Self::UnionType) { 1962 1958 self.close_currently_open_item(); 1963 1959 } 1964 1960 ··· 1977 1973 name: &str, 1978 1974 _arity: usize, 1979 1975 arguments_names: impl IntoIterator<Item = Name>, 1980 - ) -> Function { 1976 + ) -> Self::Function { 1981 1977 self.new_top_level_form(); 1982 1978 self.code.push_str(&quote_atom_name(name)); 1983 1979 self.code.push('('); ··· 1996 1992 self.indentation += INDENT; 1997 1993 self.position 1998 1994 .push(ErlangSourceBuilderPosition::FunctionStatement { first: true }); 1999 - 2000 - Function {} 2001 1995 } 2002 1996 2003 1997 fn start_anonymous_function<Name: AsRef<str>>( 2004 1998 &mut self, 2005 1999 arguments_names: impl IntoIterator<Item = Name>, 2006 - ) -> Function { 2000 + ) -> Self::Function { 2007 2001 self.new_expression(); 2008 2002 self.code.push_str("fun("); 2009 2003 ··· 2021 2015 self.indentation += INDENT; 2022 2016 self.position 2023 2017 .push(ErlangSourceBuilderPosition::AnonymousFunctionStatement { first: true }); 2024 - 2025 - Function {} 2026 2018 } 2027 2019 2028 - fn end_function(&mut self, _function: Function) { 2020 + fn end_function(&mut self, _function: Self::Function) { 2029 2021 self.close_currently_open_item(); 2030 2022 } 2031 2023 2032 - fn start_block(&mut self) -> Block { 2024 + fn start_block(&mut self) -> Self::Block { 2033 2025 self.new_expression(); 2034 2026 self.code.push_str("begin"); 2035 2027 self.indentation += INDENT; 2036 2028 self.position 2037 2029 .push(ErlangSourceBuilderPosition::Block { first: true }); 2038 - 2039 - Block {} 2040 2030 } 2041 2031 2042 - fn end_block(&mut self, _block: Block) { 2032 + fn end_block(&mut self, _block: Self::Block) { 2043 2033 self.close_currently_open_item(); 2044 2034 } 2045 2035 2046 - fn start_remote_call(&mut self, module: ErlangModuleName, function: &str) -> Call { 2036 + fn start_remote_call(&mut self, module: ErlangModuleName, function: &str) -> Self::Call { 2047 2037 self.pop_leftover_items(); 2048 2038 2049 2039 // If this function call we're generating is itself being called then ··· 2067 2057 expected: ExpectedCallItem::Arguments { first: true }, 2068 2058 called_item_needs_wrapping: false, 2069 2059 }); 2070 - Call {} 2071 2060 } 2072 2061 2073 - fn start_call(&mut self) -> Call { 2062 + fn start_call(&mut self) -> Self::Call { 2074 2063 self.pop_leftover_items(); 2075 2064 2076 2065 // If this function call we're generating is itself being called then ··· 2091 2080 expected: ExpectedCallItem::FunctionToBeCalled, 2092 2081 called_item_needs_wrapping: false, 2093 2082 }); 2094 - Call {} 2095 2083 } 2096 2084 2097 - fn end_call(&mut self, _call: Call) { 2085 + fn end_call(&mut self, _call: Self::Call) { 2098 2086 self.close_currently_open_item(); 2099 2087 } 2100 2088 2101 - fn start_tuple(&mut self) -> Tuple { 2089 + fn start_tuple(&mut self) -> Self::Tuple { 2102 2090 self.new_expression(); 2103 2091 self.code.push('{'); 2104 2092 self.position 2105 2093 .push(ErlangSourceBuilderPosition::Tuple { first: true }); 2106 - 2107 - Tuple {} 2108 2094 } 2109 2095 2110 - fn end_tuple(&mut self, _tuple: Tuple) { 2096 + fn end_tuple(&mut self, _tuple: Self::Tuple) { 2111 2097 self.close_currently_open_item(); 2112 2098 } 2113 2099 2114 - fn start_map(&mut self) -> Map { 2100 + fn start_map(&mut self) -> Self::Map { 2115 2101 self.new_expression(); 2116 2102 self.code.push_str("#{"); 2117 2103 self.indentation += INDENT; 2118 2104 self.position 2119 2105 .push(ErlangSourceBuilderPosition::Map { first: true }); 2120 - Map {} 2121 2106 } 2122 2107 2123 - fn end_map(&mut self, _map: Map) { 2108 + fn end_map(&mut self, _map: Self::Map) { 2124 2109 self.close_currently_open_item(); 2125 2110 } 2126 2111 ··· 2131 2116 }); 2132 2117 } 2133 2118 2134 - fn start_bit_array(&mut self) -> BitArray { 2119 + fn start_bit_array(&mut self) -> Self::BitArray { 2135 2120 self.do_not_wrap_if_segment_value_or_size(); 2136 2121 self.new_expression(); 2137 2122 self.code.push_str("<<"); ··· 2139 2124 kind: BitArrayKind::Expression, 2140 2125 first: true, 2141 2126 }); 2142 - 2143 - BitArray {} 2144 2127 } 2145 2128 2146 - fn end_bit_array(&mut self, _bit_array: BitArray) { 2129 + fn end_bit_array(&mut self, _bit_array: Self::BitArray) { 2147 2130 self.close_currently_open_item(); 2148 2131 } 2149 2132 ··· 2230 2213 self.empty_list_of_kind(ListKind::Expression); 2231 2214 } 2232 2215 2233 - fn start_case(&mut self) -> Case { 2216 + fn start_case(&mut self) -> Self::Case { 2234 2217 self.new_expression(); 2235 2218 self.code.push_str("case "); 2236 2219 self.position.push(ErlangSourceBuilderPosition::Case { 2237 2220 expected: ExpectedCaseItem::Subject, 2238 2221 }); 2239 - 2240 - Case {} 2241 2222 } 2242 2223 2243 - fn end_case(&mut self, _case: Case) { 2224 + fn end_case(&mut self, _case: Self::Case) { 2244 2225 self.close_currently_open_item(); 2245 2226 } 2246 2227 2247 - fn start_case_clause(&mut self) -> ClausePattern { 2228 + fn start_case_clause(&mut self) -> Self::ClausePattern { 2248 2229 self.new_case_clause(); 2249 2230 self.position.push(ErlangSourceBuilderPosition::CaseClause { 2250 2231 expected: ExpectedCaseClauseItem::Pattern, 2251 2232 }); 2252 - ClausePattern {} 2253 2233 } 2254 2234 2255 - fn end_clause_pattern(&mut self, _clause_pattern: ClausePattern) -> ClauseGuards { 2235 + fn end_clause_pattern(&mut self, _clause_pattern: Self::ClausePattern) -> Self::ClauseGuards { 2256 2236 self.close_currently_open_item(); 2257 2237 self.position.push(ErlangSourceBuilderPosition::CaseClause { 2258 2238 expected: ExpectedCaseClauseItem::Guards { first: true }, 2259 2239 }); 2260 - 2261 - ClauseGuards {} 2262 2240 } 2263 2241 2264 - fn end_clause_guards(&mut self, _clause_guards: ClauseGuards) -> ClauseBody { 2242 + fn end_clause_guards(&mut self, _clause_guards: Self::ClauseGuards) -> Self::ClauseBody { 2265 2243 self.close_currently_open_item(); 2266 2244 self.indentation += INDENT; 2267 2245 self.position.push(ErlangSourceBuilderPosition::CaseClause { 2268 2246 expected: ExpectedCaseClauseItem::Body { first: true }, 2269 2247 }); 2270 - 2271 - ClauseBody {} 2272 2248 } 2273 2249 2274 - fn end_clause_body(&mut self, _clause_body: ClauseBody) { 2250 + fn end_clause_body(&mut self, _clause_body: Self::ClauseBody) { 2275 2251 self.close_currently_open_item(); 2276 2252 } 2277 2253 ··· 2376 2352 self.code.push_str(&quote_atom_name(name)); 2377 2353 } 2378 2354 2379 - fn start_tuple_pattern(&mut self) -> TuplePattern { 2355 + fn start_tuple_pattern(&mut self) -> Self::TuplePattern { 2380 2356 self.new_pattern(); 2381 2357 self.code.push('{'); 2382 2358 self.position 2383 2359 .push(ErlangSourceBuilderPosition::TuplePattern { first: true }); 2384 - TuplePattern {} 2385 2360 } 2386 2361 2387 - fn end_tuple_pattern(&mut self, _tuple: TuplePattern) { 2362 + fn end_tuple_pattern(&mut self, _tuple: Self::TuplePattern) { 2388 2363 self.close_currently_open_item(); 2389 2364 } 2390 2365 2391 - fn start_bit_array_pattern(&mut self) -> BitArrayPattern { 2366 + fn start_bit_array_pattern(&mut self) -> Self::BitArrayPattern { 2392 2367 self.new_pattern(); 2393 2368 self.code.push_str("<<"); 2394 2369 self.position.push(ErlangSourceBuilderPosition::BitArray { 2395 2370 kind: BitArrayKind::Pattern, 2396 2371 first: true, 2397 2372 }); 2398 - 2399 - BitArrayPattern {} 2400 2373 } 2401 2374 2402 - fn end_bit_array_pattern(&mut self, _bit_array: BitArrayPattern) { 2375 + fn end_bit_array_pattern(&mut self, _bit_array: Self::BitArrayPattern) { 2403 2376 self.close_currently_open_item(); 2404 2377 } 2405 2378