From 71cc8d4c4b7b8fb3e5fe28833e95826c179c783d Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Fri, 12 Nov 2021 11:09:52 -0800 Subject: [PATCH] Convert requires_rigids to collection_trailing_sep_e --- compiler/load/src/file.rs | 3 +-- compiler/parse/src/header.rs | 4 ++-- compiler/parse/src/module.rs | 8 +++++--- compiler/parse/src/parser.rs | 1 + compiler/parse/tests/test_parse.rs | 10 ++++++++-- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/compiler/load/src/file.rs b/compiler/load/src/file.rs index 11c30c2dc7..eb77687428 100644 --- a/compiler/load/src/file.rs +++ b/compiler/load/src/file.rs @@ -3409,8 +3409,7 @@ fn fabricate_pkg_config_module<'a>( header_src: &'a str, module_timing: ModuleTiming, ) -> (ModuleId, Msg<'a>) { - let provides: &'a [Located>] = - header.provides.items; + let provides: &'a [Located>] = header.provides.items; let info = PlatformHeaderInfo { filename, diff --git a/compiler/parse/src/header.rs b/compiler/parse/src/header.rs index 37475ebce1..f7ec7139b9 100644 --- a/compiler/parse/src/header.rs +++ b/compiler/parse/src/header.rs @@ -117,7 +117,7 @@ pub struct PackageHeader<'a> { pub after_imports: &'a [CommentOrNewline<'a>], } -#[derive(Clone, Debug, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq)] pub enum PlatformRigid<'a> { Entry { rigid: &'a str, alias: &'a str }, @@ -137,7 +137,7 @@ impl<'a> Spaceable<'a> for PlatformRigid<'a> { #[derive(Clone, Debug, PartialEq)] pub struct PlatformRequires<'a> { - pub rigids: Vec<'a, Loc>>, + pub rigids: Collection<'a, Loc>>, pub signature: Loc>, } diff --git a/compiler/parse/src/module.rs b/compiler/parse/src/module.rs index 4a31995e91..e6a8d9a6e3 100644 --- a/compiler/parse/src/module.rs +++ b/compiler/parse/src/module.rs @@ -444,15 +444,17 @@ fn platform_requires<'a>() -> impl Parser<'a, PlatformRequires<'a>, ERequires<'a #[inline(always)] fn requires_rigids<'a>( min_indent: u16, -) -> impl Parser<'a, Vec<'a, Located>>, ERequires<'a>> { - collection_e!( +) -> impl Parser<'a, Collection<'a, Located>>, ERequires<'a>> { + collection_trailing_sep_e!( word1(b'{', ERequires::ListStart), specialize(|_, r, c| ERequires::Rigid(r, c), loc!(requires_rigid())), word1(b',', ERequires::ListEnd), word1(b'}', ERequires::ListEnd), min_indent, + ERequires::Open, ERequires::Space, - ERequires::IndentListEnd + ERequires::IndentListEnd, + PlatformRigid::SpaceBefore ) } diff --git a/compiler/parse/src/parser.rs b/compiler/parse/src/parser.rs index 4b0270e74a..1c176893d5 100644 --- a/compiler/parse/src/parser.rs +++ b/compiler/parse/src/parser.rs @@ -243,6 +243,7 @@ pub enum EExposes { #[derive(Debug, Clone, PartialEq, Eq)] pub enum ERequires<'a> { Requires(Row, Col), + Open(Row, Col), IndentRequires(Row, Col), IndentListStart(Row, Col), IndentListEnd(Row, Col), diff --git a/compiler/parse/tests/test_parse.rs b/compiler/parse/tests/test_parse.rs index b3b3779bd4..5a194088f5 100644 --- a/compiler/parse/tests/test_parse.rs +++ b/compiler/parse/tests/test_parse.rs @@ -3318,7 +3318,7 @@ mod test_parse { let region2 = Region::new(0, 0, 45, 47); PlatformRequires { - rigids: Vec::new_in(&arena), + rigids: Collection::empty(), signature: Located::at( region1, TypedIdent::Entry { @@ -3403,7 +3403,13 @@ mod test_parse { let region3 = Region::new(1, 1, 14, 26); PlatformRequires { - rigids: bumpalo::vec![ in &arena; Located::at(region3, PlatformRigid::Entry { alias: "Model", rigid: "model" }) ], + rigids: Collection::with_items(arena.alloc([Located::at( + region3, + PlatformRigid::Entry { + alias: "Model", + rigid: "model", + }, + )])), signature: Located::at( region1, TypedIdent::Entry {