mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
rust update, nix update, clippy fixes
This commit is contained in:
parent
32fcb38a94
commit
e784baccce
37 changed files with 289 additions and 244 deletions
|
@ -65,15 +65,15 @@ impl Newlines {
|
|||
pub trait Formattable {
|
||||
fn is_multiline(&self) -> bool;
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
_parens: Parens,
|
||||
_newlines: Newlines,
|
||||
indent: u16,
|
||||
);
|
||||
|
||||
fn format<'buf>(&self, buf: &mut Buf<'buf>, indent: u16) {
|
||||
fn format(&self, buf: &mut Buf, indent: u16) {
|
||||
self.format_with_options(buf, Parens::NotNeeded, Newlines::No, indent);
|
||||
}
|
||||
}
|
||||
|
@ -87,9 +87,9 @@ where
|
|||
(*self).is_multiline()
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
parens: Parens,
|
||||
newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -97,7 +97,7 @@ where
|
|||
(*self).format_with_options(buf, parens, newlines, indent)
|
||||
}
|
||||
|
||||
fn format<'buf>(&self, buf: &mut Buf<'buf>, indent: u16) {
|
||||
fn format(&self, buf: &mut Buf, indent: u16) {
|
||||
(*self).format(buf, indent)
|
||||
}
|
||||
}
|
||||
|
@ -120,9 +120,9 @@ where
|
|||
self.value.is_multiline()
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
parens: Parens,
|
||||
newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -131,7 +131,7 @@ where
|
|||
.format_with_options(buf, parens, newlines, indent)
|
||||
}
|
||||
|
||||
fn format<'buf>(&self, buf: &mut Buf<'buf>, indent: u16) {
|
||||
fn format(&self, buf: &mut Buf, indent: u16) {
|
||||
self.value.format(buf, indent)
|
||||
}
|
||||
}
|
||||
|
@ -141,9 +141,9 @@ impl<'a> Formattable for UppercaseIdent<'a> {
|
|||
false
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
_parens: Parens,
|
||||
_newlines: Newlines,
|
||||
_indent: u16,
|
||||
|
@ -206,9 +206,9 @@ impl<'a> Formattable for TypeAnnotation<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
parens: Parens,
|
||||
newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -424,9 +424,9 @@ impl<'a> Formattable for AssignedField<'a, TypeAnnotation<'a>> {
|
|||
is_multiline_assigned_field_help(self)
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
_parens: Parens,
|
||||
newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -441,9 +441,9 @@ impl<'a> Formattable for AssignedField<'a, Expr<'a>> {
|
|||
is_multiline_assigned_field_help(self)
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
_parens: Parens,
|
||||
newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -466,9 +466,9 @@ fn is_multiline_assigned_field_help<T: Formattable>(afield: &AssignedField<'_, T
|
|||
}
|
||||
}
|
||||
|
||||
fn format_assigned_field_help<'a, 'buf, T>(
|
||||
zelf: &AssignedField<'a, T>,
|
||||
buf: &mut Buf<'buf>,
|
||||
fn format_assigned_field_help< T>(
|
||||
zelf: &AssignedField<T>,
|
||||
buf: &mut Buf,
|
||||
indent: u16,
|
||||
separator_spaces: usize,
|
||||
is_multiline: bool,
|
||||
|
@ -545,9 +545,9 @@ impl<'a> Formattable for Tag<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
_parens: Parens,
|
||||
_newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -592,9 +592,9 @@ impl<'a> Formattable for HasClause<'a> {
|
|||
false
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
parens: Parens,
|
||||
newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -623,9 +623,9 @@ impl<'a> Formattable for HasImpls<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
parens: Parens,
|
||||
newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -662,9 +662,9 @@ impl<'a> Formattable for HasAbility<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
parens: Parens,
|
||||
newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -703,9 +703,9 @@ impl<'a> Formattable for HasAbilities<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
parens: Parens,
|
||||
newlines: Newlines,
|
||||
indent: u16,
|
||||
|
|
|
@ -15,9 +15,9 @@ impl<'a> Formattable for Defs<'a> {
|
|||
!self.tags.is_empty()
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
_parens: Parens,
|
||||
_newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -57,9 +57,9 @@ impl<'a> Formattable for TypeDef<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
_parens: Parens,
|
||||
newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -171,9 +171,9 @@ impl<'a> Formattable for TypeHeader<'a> {
|
|||
self.vars.iter().any(|v| v.is_multiline())
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
_parens: Parens,
|
||||
_newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -205,9 +205,9 @@ impl<'a> Formattable for ValueDef<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
_parens: Parens,
|
||||
newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -314,8 +314,8 @@ fn should_outdent(mut rhs: &TypeAnnotation) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
fn fmt_dbg_in_def<'a, 'buf>(
|
||||
buf: &mut Buf<'buf>,
|
||||
fn fmt_dbg_in_def<'a>(
|
||||
buf: &mut Buf,
|
||||
condition: &'a Loc<Expr<'a>>,
|
||||
is_multiline: bool,
|
||||
indent: u16,
|
||||
|
@ -335,8 +335,8 @@ fn fmt_dbg_in_def<'a, 'buf>(
|
|||
condition.format(buf, return_indent);
|
||||
}
|
||||
|
||||
fn fmt_expect<'a, 'buf>(
|
||||
buf: &mut Buf<'buf>,
|
||||
fn fmt_expect<'a>(
|
||||
buf: &mut Buf,
|
||||
condition: &'a Loc<Expr<'a>>,
|
||||
is_multiline: bool,
|
||||
indent: u16,
|
||||
|
@ -356,8 +356,8 @@ fn fmt_expect<'a, 'buf>(
|
|||
condition.format(buf, return_indent);
|
||||
}
|
||||
|
||||
fn fmt_expect_fx<'a, 'buf>(
|
||||
buf: &mut Buf<'buf>,
|
||||
fn fmt_expect_fx<'a>(
|
||||
buf: &mut Buf,
|
||||
condition: &'a Loc<Expr<'a>>,
|
||||
is_multiline: bool,
|
||||
indent: u16,
|
||||
|
@ -377,24 +377,24 @@ fn fmt_expect_fx<'a, 'buf>(
|
|||
condition.format(buf, return_indent);
|
||||
}
|
||||
|
||||
pub fn fmt_value_def<'a, 'buf>(
|
||||
buf: &mut Buf<'buf>,
|
||||
def: &roc_parse::ast::ValueDef<'a>,
|
||||
pub fn fmt_value_def(
|
||||
buf: &mut Buf,
|
||||
def: &roc_parse::ast::ValueDef,
|
||||
indent: u16,
|
||||
) {
|
||||
def.format(buf, indent);
|
||||
}
|
||||
|
||||
pub fn fmt_type_def<'a, 'buf>(buf: &mut Buf<'buf>, def: &roc_parse::ast::TypeDef<'a>, indent: u16) {
|
||||
pub fn fmt_type_def(buf: &mut Buf, def: &roc_parse::ast::TypeDef, indent: u16) {
|
||||
def.format(buf, indent);
|
||||
}
|
||||
|
||||
pub fn fmt_defs<'a, 'buf>(buf: &mut Buf<'buf>, defs: &Defs<'a>, indent: u16) {
|
||||
pub fn fmt_defs(buf: &mut Buf, defs: &Defs, indent: u16) {
|
||||
defs.format(buf, indent);
|
||||
}
|
||||
|
||||
pub fn fmt_body<'a, 'buf>(
|
||||
buf: &mut Buf<'buf>,
|
||||
pub fn fmt_body<'a>(
|
||||
buf: &mut Buf,
|
||||
pattern: &'a Pattern<'a>,
|
||||
body: &'a Expr<'a>,
|
||||
indent: u16,
|
||||
|
@ -462,9 +462,9 @@ impl<'a> Formattable for AbilityMember<'a> {
|
|||
self.name.value.is_multiline() || self.typ.is_multiline()
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
_parens: Parens,
|
||||
_newlines: Newlines,
|
||||
indent: u16,
|
||||
|
|
|
@ -103,9 +103,9 @@ impl<'a> Formattable for Expr<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
parens: Parens,
|
||||
newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -551,7 +551,7 @@ fn starts_with_newline(expr: &Expr) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
fn format_str_segment<'a, 'buf>(seg: &StrSegment<'a>, buf: &mut Buf<'buf>, indent: u16) {
|
||||
fn format_str_segment(seg: &StrSegment, buf: &mut Buf, indent: u16) {
|
||||
use StrSegment::*;
|
||||
|
||||
match seg {
|
||||
|
@ -614,7 +614,7 @@ fn push_op(buf: &mut Buf, op: BinOp) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn fmt_str_literal<'buf>(buf: &mut Buf<'buf>, literal: StrLiteral, indent: u16) {
|
||||
pub fn fmt_str_literal(buf: &mut Buf, literal: StrLiteral, indent: u16) {
|
||||
use roc_parse::ast::StrLiteral::*;
|
||||
|
||||
match literal {
|
||||
|
@ -673,8 +673,8 @@ pub fn fmt_str_literal<'buf>(buf: &mut Buf<'buf>, literal: StrLiteral, indent: u
|
|||
}
|
||||
}
|
||||
|
||||
fn fmt_binops<'a, 'buf>(
|
||||
buf: &mut Buf<'buf>,
|
||||
fn fmt_binops<'a>(
|
||||
buf: &mut Buf,
|
||||
lefts: &'a [(Loc<Expr<'a>>, Loc<BinOp>)],
|
||||
loc_right_side: &'a Loc<Expr<'a>>,
|
||||
part_of_multi_line_binops: bool,
|
||||
|
@ -704,9 +704,9 @@ fn fmt_binops<'a, 'buf>(
|
|||
loc_right_side.format_with_options(buf, Parens::InOperator, Newlines::Yes, indent);
|
||||
}
|
||||
|
||||
fn format_spaces<'a, 'buf>(
|
||||
buf: &mut Buf<'buf>,
|
||||
spaces: &[CommentOrNewline<'a>],
|
||||
fn format_spaces(
|
||||
buf: &mut Buf,
|
||||
spaces: &[CommentOrNewline],
|
||||
newlines: Newlines,
|
||||
indent: u16,
|
||||
) {
|
||||
|
@ -738,8 +738,8 @@ fn is_when_patterns_multiline(when_branch: &WhenBranch) -> bool {
|
|||
is_multiline_patterns
|
||||
}
|
||||
|
||||
fn fmt_when<'a, 'buf>(
|
||||
buf: &mut Buf<'buf>,
|
||||
fn fmt_when<'a>(
|
||||
buf: &mut Buf,
|
||||
loc_condition: &'a Loc<Expr<'a>>,
|
||||
branches: &[&'a WhenBranch<'a>],
|
||||
indent: u16,
|
||||
|
@ -920,8 +920,8 @@ fn fmt_when<'a, 'buf>(
|
|||
}
|
||||
}
|
||||
|
||||
fn fmt_dbg<'a, 'buf>(
|
||||
buf: &mut Buf<'buf>,
|
||||
fn fmt_dbg<'a>(
|
||||
buf: &mut Buf,
|
||||
condition: &'a Loc<Expr<'a>>,
|
||||
continuation: &'a Loc<Expr<'a>>,
|
||||
is_multiline: bool,
|
||||
|
@ -947,8 +947,8 @@ fn fmt_dbg<'a, 'buf>(
|
|||
continuation.format(buf, indent);
|
||||
}
|
||||
|
||||
fn fmt_expect<'a, 'buf>(
|
||||
buf: &mut Buf<'buf>,
|
||||
fn fmt_expect<'a>(
|
||||
buf: &mut Buf,
|
||||
condition: &'a Loc<Expr<'a>>,
|
||||
continuation: &'a Loc<Expr<'a>>,
|
||||
is_multiline: bool,
|
||||
|
@ -974,8 +974,8 @@ fn fmt_expect<'a, 'buf>(
|
|||
continuation.format(buf, indent);
|
||||
}
|
||||
|
||||
fn fmt_if<'a, 'buf>(
|
||||
buf: &mut Buf<'buf>,
|
||||
fn fmt_if<'a>(
|
||||
buf: &mut Buf,
|
||||
branches: &'a [(Loc<Expr<'a>>, Loc<Expr<'a>>)],
|
||||
final_else: &'a Loc<Expr<'a>>,
|
||||
is_multiline: bool,
|
||||
|
@ -1123,8 +1123,8 @@ fn fmt_if<'a, 'buf>(
|
|||
final_else.format(buf, return_indent);
|
||||
}
|
||||
|
||||
fn fmt_closure<'a, 'buf>(
|
||||
buf: &mut Buf<'buf>,
|
||||
fn fmt_closure<'a>(
|
||||
buf: &mut Buf,
|
||||
loc_patterns: &'a [Loc<Pattern<'a>>],
|
||||
loc_ret: &'a Loc<Expr<'a>>,
|
||||
indent: u16,
|
||||
|
@ -1224,8 +1224,8 @@ fn fmt_closure<'a, 'buf>(
|
|||
}
|
||||
}
|
||||
|
||||
fn fmt_backpassing<'a, 'buf>(
|
||||
buf: &mut Buf<'buf>,
|
||||
fn fmt_backpassing<'a>(
|
||||
buf: &mut Buf,
|
||||
loc_patterns: &'a [Loc<Pattern<'a>>],
|
||||
loc_body: &'a Loc<Expr<'a>>,
|
||||
loc_ret: &'a Loc<Expr<'a>>,
|
||||
|
@ -1312,8 +1312,8 @@ fn pattern_needs_parens_when_backpassing(pat: &Pattern) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
fn fmt_record<'a, 'buf>(
|
||||
buf: &mut Buf<'buf>,
|
||||
fn fmt_record<'a>(
|
||||
buf: &mut Buf,
|
||||
update: Option<&'a Loc<Expr<'a>>>,
|
||||
fields: Collection<'a, Loc<AssignedField<'a, Expr<'a>>>>,
|
||||
indent: u16,
|
||||
|
@ -1404,9 +1404,9 @@ fn fmt_record<'a, 'buf>(
|
|||
}
|
||||
}
|
||||
|
||||
fn format_field_multiline<'a, 'buf, T>(
|
||||
buf: &mut Buf<'buf>,
|
||||
field: &AssignedField<'a, T>,
|
||||
fn format_field_multiline<T>(
|
||||
buf: &mut Buf,
|
||||
field: &AssignedField<T>,
|
||||
indent: u16,
|
||||
separator_prefix: &str,
|
||||
) where
|
||||
|
|
|
@ -86,9 +86,9 @@ impl<V: Formattable> Formattable for Option<V> {
|
|||
}
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
parens: crate::annotation::Parens,
|
||||
newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -111,9 +111,9 @@ impl<'a> Formattable for ProvidesTo<'a> {
|
|||
|| self.to_keyword.is_multiline()
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
_parens: crate::annotation::Parens,
|
||||
_newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -130,9 +130,9 @@ impl<'a> Formattable for PlatformRequires<'a> {
|
|||
is_collection_multiline(&self.rigids) || self.signature.is_multiline()
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
_parens: crate::annotation::Parens,
|
||||
_newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -146,9 +146,9 @@ impl<'a, V: Formattable> Formattable for Spaces<'a, V> {
|
|||
!self.before.is_empty() || !self.after.is_empty() || self.item.is_multiline()
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
parens: crate::annotation::Parens,
|
||||
newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -164,9 +164,9 @@ impl<'a, K: Formattable, V: Formattable> Formattable for KeywordItem<'a, K, V> {
|
|||
self.keyword.is_multiline() || self.item.is_multiline()
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
parens: Parens,
|
||||
newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -177,7 +177,7 @@ impl<'a, K: Formattable, V: Formattable> Formattable for KeywordItem<'a, K, V> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn fmt_interface_header<'a, 'buf>(buf: &mut Buf<'buf>, header: &'a InterfaceHeader<'a>) {
|
||||
pub fn fmt_interface_header<'a>(buf: &mut Buf, header: &'a InterfaceHeader<'a>) {
|
||||
buf.indent(0);
|
||||
buf.push_str("interface");
|
||||
let indent = INDENT;
|
||||
|
@ -193,7 +193,7 @@ pub fn fmt_interface_header<'a, 'buf>(buf: &mut Buf<'buf>, header: &'a Interface
|
|||
fmt_imports(buf, header.imports.item, indent);
|
||||
}
|
||||
|
||||
pub fn fmt_hosted_header<'a, 'buf>(buf: &mut Buf<'buf>, header: &'a HostedHeader<'a>) {
|
||||
pub fn fmt_hosted_header<'a>(buf: &mut Buf, header: &'a HostedHeader<'a>) {
|
||||
buf.indent(0);
|
||||
buf.push_str("hosted");
|
||||
let indent = INDENT;
|
||||
|
@ -210,7 +210,7 @@ pub fn fmt_hosted_header<'a, 'buf>(buf: &mut Buf<'buf>, header: &'a HostedHeader
|
|||
fmt_exposes(buf, header.generates_with.item, indent);
|
||||
}
|
||||
|
||||
pub fn fmt_app_header<'a, 'buf>(buf: &mut Buf<'buf>, header: &'a AppHeader<'a>) {
|
||||
pub fn fmt_app_header<'a>(buf: &mut Buf, header: &'a AppHeader<'a>) {
|
||||
buf.indent(0);
|
||||
buf.push_str("app");
|
||||
let indent = INDENT;
|
||||
|
@ -229,7 +229,7 @@ pub fn fmt_app_header<'a, 'buf>(buf: &mut Buf<'buf>, header: &'a AppHeader<'a>)
|
|||
header.provides.format(buf, indent);
|
||||
}
|
||||
|
||||
pub fn fmt_package_header<'a, 'buf>(buf: &mut Buf<'buf>, header: &'a PackageHeader<'a>) {
|
||||
pub fn fmt_package_header<'a>(buf: &mut Buf, header: &'a PackageHeader<'a>) {
|
||||
buf.indent(0);
|
||||
buf.push_str("package");
|
||||
let indent = INDENT;
|
||||
|
@ -243,7 +243,7 @@ pub fn fmt_package_header<'a, 'buf>(buf: &mut Buf<'buf>, header: &'a PackageHead
|
|||
fmt_packages(buf, header.packages.item, indent);
|
||||
}
|
||||
|
||||
pub fn fmt_platform_header<'a, 'buf>(buf: &mut Buf<'buf>, header: &'a PlatformHeader<'a>) {
|
||||
pub fn fmt_platform_header<'a>(buf: &mut Buf, header: &'a PlatformHeader<'a>) {
|
||||
buf.indent(0);
|
||||
buf.push_str("platform");
|
||||
let indent = INDENT;
|
||||
|
@ -262,7 +262,7 @@ pub fn fmt_platform_header<'a, 'buf>(buf: &mut Buf<'buf>, header: &'a PlatformHe
|
|||
fmt_provides(buf, header.provides.item, None, indent);
|
||||
}
|
||||
|
||||
fn fmt_requires<'a, 'buf>(buf: &mut Buf<'buf>, requires: &PlatformRequires<'a>, indent: u16) {
|
||||
fn fmt_requires(buf: &mut Buf, requires: &PlatformRequires, indent: u16) {
|
||||
fmt_collection(buf, indent, Braces::Curly, requires.rigids, Newlines::No);
|
||||
|
||||
buf.push_str(" {");
|
||||
|
@ -276,9 +276,9 @@ impl<'a> Formattable for TypedIdent<'a> {
|
|||
false
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
_parens: Parens,
|
||||
_newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -293,7 +293,7 @@ impl<'a> Formattable for TypedIdent<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn fmt_package_name<'buf>(buf: &mut Buf<'buf>, name: PackageName, indent: u16) {
|
||||
fn fmt_package_name(buf: &mut Buf, name: PackageName, indent: u16) {
|
||||
buf.indent(indent);
|
||||
buf.push('"');
|
||||
buf.push_str_allow_spaces(name.to_str());
|
||||
|
@ -312,9 +312,9 @@ impl<'a, T: Formattable> Formattable for Spaced<'a, T> {
|
|||
}
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
parens: crate::annotation::Parens,
|
||||
newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -335,16 +335,16 @@ impl<'a, T: Formattable> Formattable for Spaced<'a, T> {
|
|||
}
|
||||
}
|
||||
|
||||
fn fmt_imports<'a, 'buf>(
|
||||
buf: &mut Buf<'buf>,
|
||||
fn fmt_imports<'a>(
|
||||
buf: &mut Buf,
|
||||
loc_entries: Collection<'a, Loc<Spaced<'a, ImportsEntry<'a>>>>,
|
||||
indent: u16,
|
||||
) {
|
||||
fmt_collection(buf, indent, Braces::Square, loc_entries, Newlines::No)
|
||||
}
|
||||
|
||||
fn fmt_provides<'a, 'buf>(
|
||||
buf: &mut Buf<'buf>,
|
||||
fn fmt_provides<'a>(
|
||||
buf: &mut Buf,
|
||||
loc_exposed_names: Collection<'a, Loc<Spaced<'a, ExposedName<'a>>>>,
|
||||
loc_provided_types: Option<Collection<'a, Loc<Spaced<'a, UppercaseIdent<'a>>>>>,
|
||||
indent: u16,
|
||||
|
@ -356,7 +356,7 @@ fn fmt_provides<'a, 'buf>(
|
|||
}
|
||||
}
|
||||
|
||||
fn fmt_to<'buf>(buf: &mut Buf<'buf>, to: To, indent: u16) {
|
||||
fn fmt_to(buf: &mut Buf, to: To, indent: u16) {
|
||||
match to {
|
||||
To::ExistingPackage(name) => {
|
||||
buf.push_str(name);
|
||||
|
@ -365,8 +365,8 @@ fn fmt_to<'buf>(buf: &mut Buf<'buf>, to: To, indent: u16) {
|
|||
}
|
||||
}
|
||||
|
||||
fn fmt_exposes<'buf, N: Formattable + Copy + core::fmt::Debug>(
|
||||
buf: &mut Buf<'buf>,
|
||||
fn fmt_exposes<N: Formattable + Copy + core::fmt::Debug>(
|
||||
buf: &mut Buf,
|
||||
loc_entries: Collection<'_, Loc<Spaced<'_, N>>>,
|
||||
indent: u16,
|
||||
) {
|
||||
|
@ -374,17 +374,17 @@ fn fmt_exposes<'buf, N: Formattable + Copy + core::fmt::Debug>(
|
|||
}
|
||||
|
||||
pub trait FormatName {
|
||||
fn format<'buf>(&self, buf: &mut Buf<'buf>);
|
||||
fn format(&self, buf: &mut Buf);
|
||||
}
|
||||
|
||||
impl<'a> FormatName for &'a str {
|
||||
fn format<'buf>(&self, buf: &mut Buf<'buf>) {
|
||||
fn format(&self, buf: &mut Buf) {
|
||||
buf.push_str(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> FormatName for ModuleName<'a> {
|
||||
fn format<'buf>(&self, buf: &mut Buf<'buf>) {
|
||||
fn format(&self, buf: &mut Buf) {
|
||||
buf.push_str(self.as_str());
|
||||
}
|
||||
}
|
||||
|
@ -394,9 +394,9 @@ impl<'a> Formattable for ModuleName<'a> {
|
|||
false
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
_parens: Parens,
|
||||
_newlines: Newlines,
|
||||
_indent: u16,
|
||||
|
@ -410,9 +410,9 @@ impl<'a> Formattable for ExposedName<'a> {
|
|||
false
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
_parens: Parens,
|
||||
_newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -423,13 +423,13 @@ impl<'a> Formattable for ExposedName<'a> {
|
|||
}
|
||||
|
||||
impl<'a> FormatName for ExposedName<'a> {
|
||||
fn format<'buf>(&self, buf: &mut Buf<'buf>) {
|
||||
fn format(&self, buf: &mut Buf) {
|
||||
buf.push_str(self.as_str());
|
||||
}
|
||||
}
|
||||
|
||||
fn fmt_packages<'a, 'buf>(
|
||||
buf: &mut Buf<'buf>,
|
||||
fn fmt_packages<'a>(
|
||||
buf: &mut Buf,
|
||||
loc_entries: Collection<'a, Loc<Spaced<'a, PackageEntry<'a>>>>,
|
||||
indent: u16,
|
||||
) {
|
||||
|
@ -441,9 +441,9 @@ impl<'a> Formattable for PackageEntry<'a> {
|
|||
false
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
_parens: Parens,
|
||||
_newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -457,9 +457,9 @@ impl<'a> Formattable for ImportsEntry<'a> {
|
|||
false
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
_parens: Parens,
|
||||
_newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -467,14 +467,14 @@ impl<'a> Formattable for ImportsEntry<'a> {
|
|||
fmt_imports_entry(buf, self, indent);
|
||||
}
|
||||
}
|
||||
fn fmt_packages_entry<'a, 'buf>(buf: &mut Buf<'buf>, entry: &PackageEntry<'a>, indent: u16) {
|
||||
fn fmt_packages_entry(buf: &mut Buf, entry: &PackageEntry, indent: u16) {
|
||||
buf.push_str(entry.shorthand);
|
||||
buf.push(':');
|
||||
fmt_default_spaces(buf, entry.spaces_after_shorthand, indent);
|
||||
fmt_package_name(buf, entry.package_name.value, indent);
|
||||
}
|
||||
|
||||
fn fmt_imports_entry<'a, 'buf>(buf: &mut Buf<'buf>, entry: &ImportsEntry<'a>, indent: u16) {
|
||||
fn fmt_imports_entry(buf: &mut Buf, entry: &ImportsEntry, indent: u16) {
|
||||
use roc_parse::header::ImportsEntry::*;
|
||||
|
||||
buf.indent(indent);
|
||||
|
|
|
@ -4,8 +4,8 @@ use crate::spaces::{fmt_comments_only, fmt_spaces, NewlineAt, INDENT};
|
|||
use crate::Buf;
|
||||
use roc_parse::ast::{Base, CommentOrNewline, Pattern, PatternAs};
|
||||
|
||||
pub fn fmt_pattern<'a, 'buf>(
|
||||
buf: &mut Buf<'buf>,
|
||||
pub fn fmt_pattern<'a>(
|
||||
buf: &mut Buf,
|
||||
pattern: &'a Pattern<'a>,
|
||||
indent: u16,
|
||||
parens: Parens,
|
||||
|
@ -18,9 +18,9 @@ impl<'a> Formattable for PatternAs<'a> {
|
|||
self.spaces_before.iter().any(|s| s.is_comment())
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
_parens: Parens,
|
||||
_newlines: Newlines,
|
||||
indent: u16,
|
||||
|
@ -85,9 +85,9 @@ impl<'a> Formattable for Pattern<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn format_with_options<'buf>(
|
||||
fn format_with_options(
|
||||
&self,
|
||||
buf: &mut Buf<'buf>,
|
||||
buf: &mut Buf,
|
||||
parens: Parens,
|
||||
newlines: Newlines,
|
||||
indent: u16,
|
||||
|
|
|
@ -21,9 +21,9 @@ use crate::{Ast, Buf};
|
|||
/// The number of spaces to indent.
|
||||
pub const INDENT: u16 = 4;
|
||||
|
||||
pub fn fmt_default_spaces<'a, 'buf>(
|
||||
buf: &mut Buf<'buf>,
|
||||
spaces: &[CommentOrNewline<'a>],
|
||||
pub fn fmt_default_spaces(
|
||||
buf: &mut Buf,
|
||||
spaces: &[CommentOrNewline],
|
||||
indent: u16,
|
||||
) {
|
||||
if spaces.is_empty() {
|
||||
|
@ -32,9 +32,9 @@ pub fn fmt_default_spaces<'a, 'buf>(
|
|||
fmt_spaces(buf, spaces.iter(), indent);
|
||||
}
|
||||
}
|
||||
pub fn fmt_default_newline<'a, 'buf>(
|
||||
buf: &mut Buf<'buf>,
|
||||
spaces: &[CommentOrNewline<'a>],
|
||||
pub fn fmt_default_newline(
|
||||
buf: &mut Buf,
|
||||
spaces: &[CommentOrNewline],
|
||||
indent: u16,
|
||||
) {
|
||||
if spaces.is_empty() {
|
||||
|
@ -153,7 +153,7 @@ pub fn fmt_comments_only<'a, 'buf, I>(
|
|||
}
|
||||
}
|
||||
|
||||
fn fmt_comment<'buf>(buf: &mut Buf<'buf>, comment: &str) {
|
||||
fn fmt_comment(buf: &mut Buf, comment: &str) {
|
||||
// The '#' in a comment should always be preceded by a newline or a space,
|
||||
// unless it's the very beginning of the buffer.
|
||||
if !buf.is_empty() && !buf.ends_with_space() && !buf.ends_with_newline() {
|
||||
|
@ -192,7 +192,7 @@ where
|
|||
count
|
||||
}
|
||||
|
||||
fn fmt_docs<'buf>(buf: &mut Buf<'buf>, docs: &str) {
|
||||
fn fmt_docs(buf: &mut Buf, docs: &str) {
|
||||
// The "##" in a doc comment should always be preceded by a newline or a space,
|
||||
// unless it's the very beginning of the buffer.
|
||||
if !buf.is_empty() && !buf.ends_with_space() && !buf.ends_with_newline() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue