mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-11 16:51:53 +03:00
Convert requires_rigids to collection_trailing_sep_e
This commit is contained in:
parent
df89fe7dd6
commit
71cc8d4c4b
@ -3409,8 +3409,7 @@ fn fabricate_pkg_config_module<'a>(
|
|||||||
header_src: &'a str,
|
header_src: &'a str,
|
||||||
module_timing: ModuleTiming,
|
module_timing: ModuleTiming,
|
||||||
) -> (ModuleId, Msg<'a>) {
|
) -> (ModuleId, Msg<'a>) {
|
||||||
let provides: &'a [Located<ExposesEntry<'a, &'a str>>] =
|
let provides: &'a [Located<ExposesEntry<'a, &'a str>>] = header.provides.items;
|
||||||
header.provides.items;
|
|
||||||
|
|
||||||
let info = PlatformHeaderInfo {
|
let info = PlatformHeaderInfo {
|
||||||
filename,
|
filename,
|
||||||
|
@ -117,7 +117,7 @@ pub struct PackageHeader<'a> {
|
|||||||
pub after_imports: &'a [CommentOrNewline<'a>],
|
pub after_imports: &'a [CommentOrNewline<'a>],
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
pub enum PlatformRigid<'a> {
|
pub enum PlatformRigid<'a> {
|
||||||
Entry { rigid: &'a str, alias: &'a str },
|
Entry { rigid: &'a str, alias: &'a str },
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ impl<'a> Spaceable<'a> for PlatformRigid<'a> {
|
|||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub struct PlatformRequires<'a> {
|
pub struct PlatformRequires<'a> {
|
||||||
pub rigids: Vec<'a, Loc<PlatformRigid<'a>>>,
|
pub rigids: Collection<'a, Loc<PlatformRigid<'a>>>,
|
||||||
pub signature: Loc<TypedIdent<'a>>,
|
pub signature: Loc<TypedIdent<'a>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,15 +444,17 @@ fn platform_requires<'a>() -> impl Parser<'a, PlatformRequires<'a>, ERequires<'a
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn requires_rigids<'a>(
|
fn requires_rigids<'a>(
|
||||||
min_indent: u16,
|
min_indent: u16,
|
||||||
) -> impl Parser<'a, Vec<'a, Located<PlatformRigid<'a>>>, ERequires<'a>> {
|
) -> impl Parser<'a, Collection<'a, Located<PlatformRigid<'a>>>, ERequires<'a>> {
|
||||||
collection_e!(
|
collection_trailing_sep_e!(
|
||||||
word1(b'{', ERequires::ListStart),
|
word1(b'{', ERequires::ListStart),
|
||||||
specialize(|_, r, c| ERequires::Rigid(r, c), loc!(requires_rigid())),
|
specialize(|_, r, c| ERequires::Rigid(r, c), loc!(requires_rigid())),
|
||||||
word1(b',', ERequires::ListEnd),
|
word1(b',', ERequires::ListEnd),
|
||||||
word1(b'}', ERequires::ListEnd),
|
word1(b'}', ERequires::ListEnd),
|
||||||
min_indent,
|
min_indent,
|
||||||
|
ERequires::Open,
|
||||||
ERequires::Space,
|
ERequires::Space,
|
||||||
ERequires::IndentListEnd
|
ERequires::IndentListEnd,
|
||||||
|
PlatformRigid::SpaceBefore
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,6 +243,7 @@ pub enum EExposes {
|
|||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum ERequires<'a> {
|
pub enum ERequires<'a> {
|
||||||
Requires(Row, Col),
|
Requires(Row, Col),
|
||||||
|
Open(Row, Col),
|
||||||
IndentRequires(Row, Col),
|
IndentRequires(Row, Col),
|
||||||
IndentListStart(Row, Col),
|
IndentListStart(Row, Col),
|
||||||
IndentListEnd(Row, Col),
|
IndentListEnd(Row, Col),
|
||||||
|
@ -3318,7 +3318,7 @@ mod test_parse {
|
|||||||
let region2 = Region::new(0, 0, 45, 47);
|
let region2 = Region::new(0, 0, 45, 47);
|
||||||
|
|
||||||
PlatformRequires {
|
PlatformRequires {
|
||||||
rigids: Vec::new_in(&arena),
|
rigids: Collection::empty(),
|
||||||
signature: Located::at(
|
signature: Located::at(
|
||||||
region1,
|
region1,
|
||||||
TypedIdent::Entry {
|
TypedIdent::Entry {
|
||||||
@ -3403,7 +3403,13 @@ mod test_parse {
|
|||||||
let region3 = Region::new(1, 1, 14, 26);
|
let region3 = Region::new(1, 1, 14, 26);
|
||||||
|
|
||||||
PlatformRequires {
|
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(
|
signature: Located::at(
|
||||||
region1,
|
region1,
|
||||||
TypedIdent::Entry {
|
TypedIdent::Entry {
|
||||||
|
Loading…
Reference in New Issue
Block a user