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

Configure Feed

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

remove redundant lifetime from formatter

author
Giacomo Cavalieri
committer
Louis Pilfold
date (Jun 7, 2026, 4:55 PM +0100) commit f6d78e7b parent 32cc941b change-id zpxvmmmt
+89 -99
+89 -99
compiler-core/src/format.rs
··· 108 108 trailing_commas: &'a [u32], 109 109 } 110 110 111 - impl<'comments> Formatter<'comments> { 111 + impl<'a> Formatter<'a> { 112 112 pub fn new() -> Self { 113 113 Default::default() 114 114 } 115 115 116 - pub(crate) fn with_comments(extra: &'comments Intermediate<'comments>) -> Self { 116 + pub(crate) fn with_comments(extra: &'a Intermediate<'a>) -> Self { 117 117 Self { 118 118 comments: &extra.comments, 119 119 doc_comments: &extra.doc_comments, ··· 159 159 fn pop_comments_with_position( 160 160 &mut self, 161 161 limit: u32, 162 - ) -> impl Iterator<Item = (u32, Option<&'comments str>)> + use<'comments> { 162 + ) -> impl Iterator<Item = (u32, Option<&'a str>)> + use<'a> { 163 163 let (popped, rest, empty_lines) = 164 164 comments_before(self.comments, self.empty_lines, limit, true); 165 165 self.comments = rest; ··· 169 169 170 170 /// Pop comments that occur before a byte-index in the source, consuming 171 171 /// and retaining any empty lines contained within. 172 - fn pop_comments( 173 - &mut self, 174 - limit: u32, 175 - ) -> impl Iterator<Item = Option<&'comments str>> + use<'comments> { 172 + fn pop_comments(&mut self, limit: u32) -> impl Iterator<Item = Option<&'a str>> + use<'a> { 176 173 self.pop_comments_with_position(limit) 177 174 .map(|(_position, comment)| comment) 178 175 } 179 176 180 177 /// Pop doc comments that occur before a byte-index in the source, consuming 181 178 /// and dropping any empty lines contained within. 182 - fn pop_doc_comments( 183 - &mut self, 184 - limit: u32, 185 - ) -> impl Iterator<Item = Option<&'comments str>> + use<'comments> { 179 + fn pop_doc_comments(&mut self, limit: u32) -> impl Iterator<Item = Option<&'a str>> + use<'a> { 186 180 let (popped, rest, empty_lines) = 187 181 comments_before(self.doc_comments, self.empty_lines, limit, false); 188 182 self.doc_comments = rest; ··· 208 202 end != 0 209 203 } 210 204 211 - fn targeted_definition<'a>(&mut self, definition: &'a TargetedDefinition) -> Document<'a> { 205 + fn targeted_definition(&mut self, definition: &'a TargetedDefinition) -> Document<'a> { 212 206 let target = definition.target; 213 207 let definition = &definition.definition; 214 208 let start = definition.location().start; ··· 225 219 comments.to_doc().append(document.group()) 226 220 } 227 221 228 - pub(crate) fn module<'a>(&mut self, module: &'a UntypedModule) -> Document<'a> { 222 + pub(crate) fn module(&mut self, module: &'a UntypedModule) -> Document<'a> { 229 223 let mut documents = vec![]; 230 224 let mut previous_was_a_definition = false; 231 225 ··· 309 303 /// import wibble 310 304 /// import wobble 311 305 /// ``` 312 - fn imports<'a>(&mut self, imports: Vec<&'a TargetedDefinition>) -> Vec<Document<'a>> { 306 + fn imports(&mut self, imports: Vec<&'a TargetedDefinition>) -> Vec<Document<'a>> { 313 307 let mut import_groups_docs = vec![]; 314 308 let mut current_group = vec![]; 315 309 let mut current_group_delimiter = nil(); ··· 361 355 362 356 /// Prints the imports as a single sorted group of import statements. 363 357 /// 364 - fn sorted_import_group<'a>(&mut self, imports: &[&'a TargetedDefinition]) -> Document<'a> { 358 + fn sorted_import_group(&mut self, imports: &[&'a TargetedDefinition]) -> Document<'a> { 365 359 let imports = imports 366 360 .iter() 367 361 .sorted_by(|one, other| match (&one.definition, &other.definition) { ··· 381 375 .to_doc() 382 376 } 383 377 384 - fn definition<'a>(&mut self, statement: &'a UntypedDefinition) -> Document<'a> { 378 + fn definition(&mut self, statement: &'a UntypedDefinition) -> Document<'a> { 385 379 match statement { 386 380 Definition::Function(function) => self.statement_fn(function), 387 381 ··· 469 463 } 470 464 } 471 465 472 - fn const_expr<'a, A>(&mut self, value: &'a Constant<A>) -> Document<'a> { 466 + fn const_expr<A>(&mut self, value: &'a Constant<A>) -> Document<'a> { 473 467 let comments = self.pop_comments(value.location().start); 474 468 let document = match value { 475 469 Constant::Todo { message, .. } => { ··· 593 587 commented(document, comments) 594 588 } 595 589 596 - fn const_list<'a, A>( 590 + fn const_list<A>( 597 591 &mut self, 598 592 elements: &'a [Constant<A>], 599 593 location: &SrcSpan, ··· 692 686 } 693 687 } 694 688 695 - pub fn const_tuple<'a, A>( 689 + pub fn const_tuple<A>( 696 690 &mut self, 697 691 elements: &'a [Constant<A>], 698 692 location: &SrcSpan, ··· 736 730 } 737 731 } 738 732 739 - fn documented_definition<'a>(&mut self, definition: &'a UntypedDefinition) -> Document<'a> { 733 + fn documented_definition(&mut self, definition: &'a UntypedDefinition) -> Document<'a> { 740 734 let comments = self.doc_comments(definition.location().start); 741 735 comments.append(self.definition(definition).group()).group() 742 736 } 743 737 744 - fn doc_comments<'a>(&mut self, limit: u32) -> Document<'a> { 738 + fn doc_comments(&mut self, limit: u32) -> Document<'a> { 745 739 let mut comments = self.pop_doc_comments(limit).peekable(); 746 740 match comments.peek() { 747 741 None => nil(), ··· 757 751 } 758 752 } 759 753 760 - fn type_ast_constructor<'a>( 754 + fn type_ast_constructor( 761 755 &mut self, 762 756 name: &'a TypeAstConstructorName, 763 757 arguments: &'a [TypeAst], ··· 780 774 } 781 775 } 782 776 783 - fn type_ast<'a>(&mut self, type_: &'a TypeAst) -> Document<'a> { 777 + fn type_ast(&mut self, type_: &'a TypeAst) -> Document<'a> { 784 778 let comments = self.pop_comments(type_.location().start); 785 779 786 780 let type_ = match type_ { ··· 819 813 commented(type_.group(), comments) 820 814 } 821 815 822 - fn type_arguments<'a>(&mut self, arguments: &'a [TypeAst], location: &SrcSpan) -> Document<'a> { 816 + fn type_arguments(&mut self, arguments: &'a [TypeAst], location: &SrcSpan) -> Document<'a> { 823 817 let arguments = arguments 824 818 .iter() 825 819 .map(|type_| self.type_ast(type_)) ··· 827 821 self.wrap_arguments(arguments, location.end) 828 822 } 829 823 830 - pub fn type_alias<'a, A>(&mut self, alias: &'a TypeAlias<A>) -> Document<'a> { 824 + pub fn type_alias<A>(&mut self, alias: &'a TypeAlias<A>) -> Document<'a> { 831 825 let TypeAlias { 832 826 alias: name, 833 827 parameters: arguments, ··· 857 851 .append(line().append(self.type_ast(type_)).group().nest(INDENT)) 858 852 } 859 853 860 - fn fn_arg<'a, A>(&mut self, argument: &'a Arg<A>) -> Document<'a> { 854 + fn fn_arg<A>(&mut self, argument: &'a Arg<A>) -> Document<'a> { 861 855 let comments = self.pop_comments(argument.location.start); 862 856 let doc = match &argument.annotation { 863 857 None => argument.names.to_doc(), ··· 871 865 commented(doc, comments) 872 866 } 873 867 874 - fn statement_fn<'a>(&mut self, function: &'a UntypedFunction) -> Document<'a> { 868 + fn statement_fn(&mut self, function: &'a UntypedFunction) -> Document<'a> { 875 869 let Function { 876 870 location, 877 871 body_start: _, ··· 949 943 docvec![attributes, function] 950 944 } 951 945 952 - fn expr_fn<'a>( 946 + fn expr_fn( 953 947 &mut self, 954 948 arguments: &'a [UntypedArg], 955 949 return_annotation: Option<&'a TypeAst>, ··· 999 993 header.append(" ").append(wrap_block(body)).group() 1000 994 } 1001 995 1002 - fn statements<'a>(&mut self, statements: &'a [UntypedStatement]) -> Document<'a> { 996 + fn statements(&mut self, statements: &'a [UntypedStatement]) -> Document<'a> { 1003 997 let mut previous_position = 0; 1004 998 let count = statements.len(); 1005 999 let mut documents = Vec::with_capacity(count * 2); ··· 1032 1026 } 1033 1027 } 1034 1028 1035 - fn assignment<'a>(&mut self, assignment: &'a UntypedAssignment) -> Document<'a> { 1029 + fn assignment(&mut self, assignment: &'a UntypedAssignment) -> Document<'a> { 1036 1030 let comments = self.pop_comments(assignment.location.start); 1037 1031 let Assignment { 1038 1032 pattern, ··· 1067 1061 ) 1068 1062 } 1069 1063 1070 - fn expr<'a>(&mut self, expression: &'a UntypedExpr) -> Document<'a> { 1064 + fn expr(&mut self, expression: &'a UntypedExpr) -> Document<'a> { 1071 1065 let comments = self.pop_comments(expression.start_byte_index()); 1072 1066 1073 1067 let document = match expression { ··· 1193 1187 commented(document, comments) 1194 1188 } 1195 1189 1196 - fn string<'a>(&self, string: &'a EcoString) -> Document<'a> { 1190 + fn string(&self, string: &'a EcoString) -> Document<'a> { 1197 1191 let doc = string.to_doc().surround("\"", "\""); 1198 1192 if string.contains('\n') { 1199 1193 doc.force_break() ··· 1202 1196 } 1203 1197 } 1204 1198 1205 - fn bin_op_string<'a>(&self, string: &'a EcoString) -> Document<'a> { 1199 + fn bin_op_string(&self, string: &'a EcoString) -> Document<'a> { 1206 1200 let lines = string.split('\n').collect_vec(); 1207 1201 match lines.as_slice() { 1208 1202 [] | [_] => string.to_doc().surround("\"", "\""), ··· 1218 1212 } 1219 1213 } 1220 1214 1221 - fn float<'a>(&self, value: &'a str) -> Document<'a> { 1215 + fn float(&self, value: &'a str) -> Document<'a> { 1222 1216 // Create parts 1223 1217 let mut parts = value.split('.'); 1224 1218 let integer_part = parts.next().unwrap_or_default(); ··· 1248 1242 .append(scientific_part) 1249 1243 } 1250 1244 1251 - fn int<'a>(&self, value: &'a str) -> Document<'a> { 1245 + fn int(&self, value: &'a str) -> Document<'a> { 1252 1246 if value.starts_with("0x") || value.starts_with("0b") || value.starts_with("0o") { 1253 1247 return value.to_doc(); 1254 1248 } ··· 1256 1250 self.underscore_integer_string(value) 1257 1251 } 1258 1252 1259 - fn underscore_integer_string<'a>(&self, value: &'a str) -> Document<'a> { 1253 + fn underscore_integer_string(&self, value: &'a str) -> Document<'a> { 1260 1254 let underscore = '_'; 1261 1255 let minus = '-'; 1262 1256 ··· 1283 1277 new_value.chars().rev().collect::<EcoString>().to_doc() 1284 1278 } 1285 1279 1286 - fn pattern_constructor<'a>( 1280 + fn pattern_constructor( 1287 1281 &mut self, 1288 1282 name: &'a str, 1289 1283 arguments: &'a [CallArg<UntypedPattern>], ··· 1343 1337 } 1344 1338 } 1345 1339 1346 - fn call<'a>( 1340 + fn call( 1347 1341 &mut self, 1348 1342 function: &'a UntypedExpr, 1349 1343 arguments: &'a [CallArg<UntypedExpr>], ··· 1384 1378 ) 1385 1379 } 1386 1380 1387 - fn tuple<'a>(&mut self, elements: &'a [UntypedExpr], location: &SrcSpan) -> Document<'a> { 1381 + fn tuple(&mut self, elements: &'a [UntypedExpr], location: &SrcSpan) -> Document<'a> { 1388 1382 if elements.is_empty() { 1389 1383 // We take all comments that come _before_ the end of the tuple, 1390 1384 // that is all comments that are inside "#(" and ")", if there's ··· 1420 1414 // resulting document will try to first split that before splitting all the 1421 1415 // other arguments. 1422 1416 // This is used for function calls and tuples. 1423 - fn append_inlinable_wrapped_arguments<'a, 'b, T, Predicate, ToDoc>( 1417 + fn append_inlinable_wrapped_arguments<'b, T, Predicate, ToDoc>( 1424 1418 &mut self, 1425 1419 doc: Document<'a>, 1426 1420 values: &'b [T], ··· 1464 1458 } 1465 1459 } 1466 1460 1467 - pub fn case<'a>( 1461 + pub fn case( 1468 1462 &mut self, 1469 1463 subjects: &'a [UntypedExpr], 1470 1464 clauses: &'a [UntypedClause], ··· 1507 1501 .force_break() 1508 1502 } 1509 1503 1510 - pub fn record_update<'a>( 1504 + pub fn record_update( 1511 1505 &mut self, 1512 1506 constructor: &'a UntypedExpr, 1513 1507 record: &'a RecordBeingUpdated<UntypedExpr>, ··· 1540 1534 ) 1541 1535 } 1542 1536 1543 - pub fn const_record_update<'a, A>( 1537 + pub fn const_record_update<A>( 1544 1538 &mut self, 1545 1539 module: &Option<(EcoString, SrcSpan)>, 1546 1540 name: &'a EcoString, ··· 1591 1585 .group() 1592 1586 } 1593 1587 1594 - pub fn bin_op<'a>( 1588 + pub fn bin_op( 1595 1589 &mut self, 1596 1590 name: &'a BinOp, 1597 1591 left: &'a UntypedExpr, ··· 1615 1609 .append(right_side) 1616 1610 } 1617 1611 1618 - fn bin_op_side<'a>( 1612 + fn bin_op_side( 1619 1613 &mut self, 1620 1614 operator: &'a BinOp, 1621 1615 side: &'a UntypedExpr, ··· 1668 1662 } 1669 1663 } 1670 1664 1671 - pub fn operator_side<'a>(&self, doc: Document<'a>, op: u8, side: u8) -> Document<'a> { 1665 + pub fn operator_side(&self, doc: Document<'a>, op: u8, side: u8) -> Document<'a> { 1672 1666 if op > side { 1673 1667 wrap_block(doc).group() 1674 1668 } else { ··· 1710 1704 .is_ok() 1711 1705 } 1712 1706 1713 - fn pipeline<'a>( 1714 - &mut self, 1715 - expressions: &'a Vec1<UntypedExpr>, 1716 - nest_pipe: bool, 1717 - ) -> Document<'a> { 1707 + fn pipeline(&mut self, expressions: &'a Vec1<UntypedExpr>, nest_pipe: bool) -> Document<'a> { 1718 1708 let mut docs = Vec::with_capacity(expressions.len() * 3); 1719 1709 let first = expressions.first(); 1720 1710 let first_precedence = first.bin_op_precedence(); ··· 1753 1743 } 1754 1744 } 1755 1745 1756 - fn fn_capture<'a>( 1746 + fn fn_capture( 1757 1747 &mut self, 1758 1748 call: &'a [UntypedStatement], 1759 1749 position: FnCapturePosition, ··· 1833 1823 } 1834 1824 } 1835 1825 1836 - pub fn record_constructor<'a, A>( 1837 - &mut self, 1838 - constructor: &'a RecordConstructor<A>, 1839 - ) -> Document<'a> { 1826 + pub fn record_constructor<A>(&mut self, constructor: &'a RecordConstructor<A>) -> Document<'a> { 1840 1827 let comments = self.pop_comments(constructor.location.start); 1841 1828 let doc_comments = self.doc_comments(constructor.location.start); 1842 1829 let attributes = AttributesPrinter::new() ··· 1890 1877 commented(doc_comments.append(doc).group(), comments) 1891 1878 } 1892 1879 1893 - pub fn custom_type<'a, A>(&mut self, type_: &'a CustomType<A>) -> Document<'a> { 1880 + pub fn custom_type<A>(&mut self, type_: &'a CustomType<A>) -> Document<'a> { 1894 1881 let CustomType { 1895 1882 location, 1896 1883 end_position, ··· 1960 1947 doc.append(inner).append(line()).append("}") 1961 1948 } 1962 1949 1963 - fn call_arg<'a>(&mut self, argument: &'a CallArg<UntypedExpr>, arity: usize) -> Document<'a> { 1950 + fn call_arg(&mut self, argument: &'a CallArg<UntypedExpr>, arity: usize) -> Document<'a> { 1964 1951 self.format_call_arg(argument, expr_call_arg_formatting, |this, value| { 1965 1952 this.comma_separated_item(value, arity) 1966 1953 }) 1967 1954 } 1968 1955 1969 - fn format_call_arg<'a, A, F, G>( 1956 + fn format_call_arg<A, F, G>( 1970 1957 &mut self, 1971 1958 argument: &'a CallArg<A>, 1972 1959 figure_formatting: F, ··· 1992 1979 } 1993 1980 } 1994 1981 1995 - fn record_update_arg<'a>(&mut self, argument: &'a UntypedRecordUpdateArg) -> Document<'a> { 1982 + fn record_update_arg(&mut self, argument: &'a UntypedRecordUpdateArg) -> Document<'a> { 1996 1983 let comments = self.pop_comments(argument.location.start); 1997 1984 match argument { 1998 1985 // Argument supplied with a label shorthand. ··· 2018 2005 } 2019 2006 } 2020 2007 2021 - fn tuple_index<'a>(&mut self, tuple: &'a UntypedExpr, index: u64) -> Document<'a> { 2008 + fn tuple_index(&mut self, tuple: &'a UntypedExpr, index: u64) -> Document<'a> { 2022 2009 // In case we have a block with a single variable tuple access we 2023 2010 // remove that redundant wrapper: 2024 2011 // ··· 2044 2031 .append(index) 2045 2032 } 2046 2033 2047 - fn case_clause_value<'a>(&mut self, expression: &'a UntypedExpr) -> Document<'a> { 2034 + fn case_clause_value(&mut self, expression: &'a UntypedExpr) -> Document<'a> { 2048 2035 match expression { 2049 2036 UntypedExpr::Fn { .. } 2050 2037 | UntypedExpr::List { .. } ··· 2088 2075 .group() 2089 2076 } 2090 2077 2091 - fn assigned_value<'a>(&mut self, expression: &'a UntypedExpr) -> Document<'a> { 2078 + fn assigned_value(&mut self, expression: &'a UntypedExpr) -> Document<'a> { 2092 2079 match expression { 2093 2080 UntypedExpr::Case { .. } => " ".to_doc().append(self.expr(expression)).group(), 2094 2081 UntypedExpr::Int { .. } ··· 2114 2101 } 2115 2102 } 2116 2103 2117 - fn clause<'a>(&mut self, clause: &'a UntypedClause, index: u32) -> Document<'a> { 2104 + fn clause(&mut self, clause: &'a UntypedClause, index: u32) -> Document<'a> { 2118 2105 let space_before = self.pop_empty_lines(clause.location.start); 2119 2106 let comments = self.pop_comments(clause.location.start); 2120 2107 ··· 2169 2156 } 2170 2157 } 2171 2158 2172 - fn alternative_patterns<'a>(&mut self, clause: &'a UntypedClause) -> Document<'a> { 2159 + fn alternative_patterns(&mut self, clause: &'a UntypedClause) -> Document<'a> { 2173 2160 let has_guard = clause.guard.is_some(); 2174 2161 let has_multiple_subjects = clause.pattern.len() > 1; 2175 2162 ··· 2232 2219 join(alternative_patterns, alternatives_separator) 2233 2220 } 2234 2221 2235 - fn list<'a>( 2222 + fn list( 2236 2223 &mut self, 2237 2224 elements: &'a [UntypedExpr], 2238 2225 tail: Option<&'a UntypedExpr>, ··· 2345 2332 } 2346 2333 } 2347 2334 2348 - fn items_sequence_packing<'a, T: HasLocation>( 2335 + fn items_sequence_packing<T: HasLocation>( 2349 2336 &self, 2350 2337 items: &'a [T], 2351 2338 tail: Option<&'a T>, ··· 2421 2408 } 2422 2409 } 2423 2410 2424 - fn has_items_on_the_same_line<'a, L: HasLocation + 'a, T: Iterator<Item = &'a L>>( 2411 + fn has_items_on_the_same_line<L: HasLocation + 'a, T: Iterator<Item = &'a L>>( 2425 2412 &self, 2426 2413 items: T, 2427 2414 ) -> bool { ··· 2442 2429 2443 2430 /// Pretty prints an expression to be used in a comma separated list; for 2444 2431 /// example as a list item, a tuple item or as an argument of a function call. 2445 - fn comma_separated_item<'a>( 2432 + fn comma_separated_item( 2446 2433 &mut self, 2447 2434 expression: &'a UntypedExpr, 2448 2435 siblings: usize, ··· 2491 2478 } 2492 2479 } 2493 2480 2494 - fn pattern<'a>(&mut self, pattern: &'a UntypedPattern) -> Document<'a> { 2481 + fn pattern(&mut self, pattern: &'a UntypedPattern) -> Document<'a> { 2495 2482 let comments = self.pop_comments(pattern.location().start); 2496 2483 let doc = match pattern { 2497 2484 Pattern::Int { value, .. } => self.int(value), ··· 2570 2557 commented(doc, comments) 2571 2558 } 2572 2559 2573 - fn bit_array_size<'a>(&mut self, size: &'a BitArraySize<()>) -> Document<'a> { 2560 + fn bit_array_size(&mut self, size: &'a BitArraySize<()>) -> Document<'a> { 2574 2561 match size { 2575 2562 BitArraySize::Int { value, .. } => self.int(value), 2576 2563 BitArraySize::Variable { name, .. } => name.to_doc(), ··· 2598 2585 } 2599 2586 } 2600 2587 2601 - fn list_pattern<'a>( 2588 + fn list_pattern( 2602 2589 &mut self, 2603 2590 elements: &'a [UntypedPattern], 2604 2591 tail: &'a Option<Box<UntypedTailPattern>>, ··· 2636 2623 .group() 2637 2624 } 2638 2625 2639 - fn pattern_call_arg<'a>(&mut self, argument: &'a CallArg<UntypedPattern>) -> Document<'a> { 2626 + fn pattern_call_arg(&mut self, argument: &'a CallArg<UntypedPattern>) -> Document<'a> { 2640 2627 self.format_call_arg(argument, pattern_call_arg_formatting, |this, value| { 2641 2628 this.pattern(value) 2642 2629 }) 2643 2630 } 2644 2631 2645 - pub fn clause_guard_bin_op<'a>( 2632 + pub fn clause_guard_bin_op( 2646 2633 &mut self, 2647 2634 name: &'a BinOp, 2648 2635 left: &'a UntypedClauseGuard, ··· 2655 2642 .append(self.clause_guard_bin_op_side(name, right, right.precedence() - 1)) 2656 2643 } 2657 2644 2658 - fn clause_guard_bin_op_side<'a>( 2645 + fn clause_guard_bin_op_side( 2659 2646 &mut self, 2660 2647 name: &BinOp, 2661 2648 side: &'a UntypedClauseGuard, ··· 2683 2670 } 2684 2671 } 2685 2672 2686 - fn clause_guard<'a>(&mut self, clause_guard: &'a UntypedClauseGuard) -> Document<'a> { 2673 + fn clause_guard(&mut self, clause_guard: &'a UntypedClauseGuard) -> Document<'a> { 2687 2674 match clause_guard { 2688 2675 ClauseGuard::Invalid { .. } => unreachable!("invalid guard made it to formatting"), 2689 2676 ··· 2720 2707 } 2721 2708 } 2722 2709 2723 - fn constant_call_arg<'a, A>(&mut self, argument: &'a CallArg<Constant<A>>) -> Document<'a> { 2710 + fn constant_call_arg<A>(&mut self, argument: &'a CallArg<Constant<A>>) -> Document<'a> { 2724 2711 self.format_call_arg(argument, constant_call_arg_formatting, |this, value| { 2725 2712 this.const_expr(value) 2726 2713 }) 2727 2714 } 2728 2715 2729 - fn negate_bool<'a>(&mut self, expression: &'a UntypedExpr) -> Document<'a> { 2716 + fn negate_bool(&mut self, expression: &'a UntypedExpr) -> Document<'a> { 2730 2717 match expression { 2731 2718 UntypedExpr::NegateBool { value, .. } => self.expr(value), 2732 2719 UntypedExpr::BinOp { .. } => "!".to_doc().append(wrap_block(self.expr(expression))), ··· 2752 2739 } 2753 2740 } 2754 2741 2755 - fn negate_int<'a>(&mut self, expression: &'a UntypedExpr) -> Document<'a> { 2742 + fn negate_int(&mut self, expression: &'a UntypedExpr) -> Document<'a> { 2756 2743 match expression { 2757 2744 UntypedExpr::NegateInt { value, .. } => self.expr(value), 2758 2745 UntypedExpr::Int { value, .. } if value.starts_with('-') => self.int(&value[1..]), ··· 2780 2767 } 2781 2768 } 2782 2769 2783 - fn use_<'a>(&mut self, use_: &'a UntypedUse) -> Document<'a> { 2770 + fn use_(&mut self, use_: &'a UntypedUse) -> Document<'a> { 2784 2771 let comments = self.pop_comments(use_.location.start); 2785 2772 2786 2773 let call = if use_.call.is_call() { ··· 2813 2800 commented(doc, comments) 2814 2801 } 2815 2802 2816 - fn assert<'a>(&mut self, assert: &'a UntypedAssert) -> Document<'a> { 2803 + fn assert(&mut self, assert: &'a UntypedAssert) -> Document<'a> { 2817 2804 let comments = self.pop_comments(assert.location.start); 2818 2805 2819 2806 let expression = if assert.value.is_binop() || assert.value.is_pipeline() { ··· 2830 2817 commented(docvec!["assert ", doc], comments) 2831 2818 } 2832 2819 2833 - fn bit_array<'a>( 2820 + fn bit_array( 2834 2821 &mut self, 2835 2822 segments: Vec<Document<'a>>, 2836 2823 packing: ItemsPacking, ··· 2889 2876 } 2890 2877 } 2891 2878 2892 - fn bit_array_segment_expr<'a>(&mut self, expression: &'a UntypedExpr) -> Document<'a> { 2879 + fn bit_array_segment_expr(&mut self, expression: &'a UntypedExpr) -> Document<'a> { 2893 2880 match expression { 2894 2881 UntypedExpr::BinOp { .. } => wrap_block(self.expr(expression)), 2895 2882 ··· 2916 2903 } 2917 2904 } 2918 2905 2919 - fn statement<'a>(&mut self, statement: &'a UntypedStatement) -> Document<'a> { 2906 + fn statement(&mut self, statement: &'a UntypedStatement) -> Document<'a> { 2920 2907 match statement { 2921 2908 Statement::Expression(expression) => self.expr(expression), 2922 2909 Statement::Assignment(assignment) => self.assignment(assignment), ··· 2925 2912 } 2926 2913 } 2927 2914 2928 - fn block<'a>( 2915 + fn block( 2929 2916 &mut self, 2930 2917 location: &SrcSpan, 2931 2918 statements: &'a Vec1<UntypedStatement>, ··· 2955 2942 } 2956 2943 } 2957 2944 2958 - pub fn wrap_function_call_arguments<'a, I>( 2945 + pub fn wrap_function_call_arguments<I>( 2959 2946 &mut self, 2960 2947 arguments: I, 2961 2948 location: &SrcSpan, ··· 2991 2978 .group() 2992 2979 } 2993 2980 2994 - pub fn wrap_arguments<'a, I>(&mut self, arguments: I, comments_limit: u32) -> Document<'a> 2981 + pub fn wrap_arguments<I>(&mut self, arguments: I, comments_limit: u32) -> Document<'a> 2995 2982 where 2996 2983 I: IntoIterator<Item = Document<'a>>, 2997 2984 { ··· 3029 3016 } 3030 3017 } 3031 3018 3032 - pub fn wrap_arguments_with_spread<'a, I>( 3019 + pub fn wrap_arguments_with_spread<I>( 3033 3020 &mut self, 3034 3021 arguments: I, 3035 3022 comments_limit: u32, ··· 3079 3066 /// `wibble`'s doc comment, so when we run into comments like `// comment` 3080 3067 /// we need to first print all documentation comments that come before it. 3081 3068 /// 3082 - fn printed_documented_comments<'a, 'b>( 3069 + fn printed_documented_comments<'b>( 3083 3070 &mut self, 3084 3071 comments: impl IntoIterator<Item = (u32, Option<&'b str>)>, 3085 3072 ) -> Option<Document<'a>> { ··· 3120 3107 Some(doc.force_break()) 3121 3108 } 3122 3109 3123 - fn append_as_message_expression<'a>( 3110 + fn append_as_message_expression( 3124 3111 &mut self, 3125 3112 doc: Document<'a>, 3126 3113 preceding_as: PrecedingAs, ··· 3177 3164 doc.group() 3178 3165 } 3179 3166 3180 - fn append_as_message_constant<'a, A>( 3167 + fn append_as_message_constant<A>( 3181 3168 &mut self, 3182 3169 doc: Document<'a>, 3183 3170 message: Option<&'a Constant<A>>, ··· 3211 3198 doc.group() 3212 3199 } 3213 3200 3214 - fn echo<'a>( 3201 + fn echo( 3215 3202 &mut self, 3216 3203 expression: &'a Option<Box<UntypedExpr>>, 3217 3204 message: &'a Option<Box<UntypedExpr>>, ··· 3478 3465 } 3479 3466 } 3480 3467 3481 - fn bit_array_segment<Value, Type, ToDoc>( 3482 - segment: &BitArraySegment<Value, Type>, 3468 + fn bit_array_segment<'a, Value, Type, ToDoc>( 3469 + segment: &'a BitArraySegment<Value, Type>, 3483 3470 mut to_doc: ToDoc, 3484 - ) -> Document<'_> 3471 + ) -> Document<'a> 3485 3472 where 3486 - ToDoc: FnMut(&Value) -> Document<'_>, 3473 + ToDoc: FnMut(&'a Value) -> Document<'a>, 3487 3474 { 3488 3475 match segment { 3489 3476 BitArraySegment { value, options, .. } if options.is_empty() => to_doc(value), ··· 3491 3478 BitArraySegment { value, options, .. } => to_doc(value).append(":").append(join( 3492 3479 options 3493 3480 .iter() 3494 - .map(|option| segment_option(option, |value| to_doc(value))), 3481 + .map(|option| segment_option(option, &mut to_doc)), 3495 3482 "-".to_doc(), 3496 3483 )), 3497 3484 } 3498 3485 } 3499 3486 3500 - fn segment_option<ToDoc, Value>(option: &BitArrayOption<Value>, mut to_doc: ToDoc) -> Document<'_> 3487 + fn segment_option<'a, ToDoc, Value>( 3488 + option: &'a BitArrayOption<Value>, 3489 + mut to_doc: ToDoc, 3490 + ) -> Document<'a> 3501 3491 where 3502 - ToDoc: FnMut(&Value) -> Document<'_>, 3492 + ToDoc: FnMut(&'a Value) -> Document<'a>, 3503 3493 { 3504 3494 match option { 3505 3495 BitArrayOption::Bytes { .. } => "bytes".to_doc(),