diff --git a/src/parse/blankspace.rs b/src/parse/blankspace.rs index bd7be84f62..71fea5390b 100644 --- a/src/parse/blankspace.rs +++ b/src/parse/blankspace.rs @@ -3,23 +3,9 @@ use bumpalo::collections::vec::Vec; use bumpalo::Bump; use parse::ast::CommentOrNewline::{self, *}; use parse::ast::Spaceable; -use parse::parser::{map_with_arena, unexpected, unexpected_eof, Parser, State}; +use parse::parser::{and, map_with_arena, unexpected, unexpected_eof, Parser, State}; use region::Located; -/// For some reason, some functions need to use this instead of using the and! macro directly. -#[inline(always)] -pub fn and<'a, P1, P2, A, B>(p1: P1, p2: P2) -> impl Parser<'a, (A, B)> -where - P1: Parser<'a, A>, - P2: Parser<'a, B>, - P1: 'a, - P2: 'a, - A: 'a, - B: 'a, -{ - and!(p1, p2) -} - /// Parses the given expression with 0 or more (spaces/comments/newlines) before and/or after it. /// Returns a Located where the location is around the Expr, ignoring the spaces. /// If any newlines or comments were found, the Expr will be wrapped in a SpaceBefore and/or diff --git a/src/parse/parser.rs b/src/parse/parser.rs index 356d31b158..4acea87d52 100644 --- a/src/parse/parser.rs +++ b/src/parse/parser.rs @@ -1,7 +1,7 @@ use bumpalo::collections::vec::Vec; use bumpalo::Bump; use parse::ast::Attempting; -use region::Region; +use region::{Located, Region}; use std::{char, u16}; /// A position in a source file. @@ -1359,3 +1359,26 @@ macro_rules! and { } }; } + +/// For some reason, some usages won't compile unless they use this instead of the macro version +#[inline(always)] +pub fn and<'a, P1, P2, A, B>(p1: P1, p2: P2) -> impl Parser<'a, (A, B)> +where + P1: Parser<'a, A>, + P2: Parser<'a, B>, + P1: 'a, + P2: 'a, + A: 'a, + B: 'a, +{ + and!(p1, p2) +} + +/// For some reason, some usages won't compile unless they use this instead of the macro version +#[inline(always)] +pub fn loc<'a, P, Val>(parser: P) -> impl Parser<'a, Located> +where + P: Parser<'a, Val>, +{ + loc!(parser) +} diff --git a/src/parse/record.rs b/src/parse/record.rs index 825327810d..f008b25a10 100644 --- a/src/parse/record.rs +++ b/src/parse/record.rs @@ -4,7 +4,7 @@ use parse::ast::Spaceable; use parse::blankspace::{space0, space0_before}; use parse::collection::collection; use parse::ident::unqualified_ident; -use parse::parser::{char, map_with_arena, optional, skip_first, Parser}; +use parse::parser::{and, char, loc, map_with_arena, optional, skip_first, Parser}; use region::Located; /// Parse a record - generally one of these two: @@ -30,29 +30,6 @@ where ) } -/// For some reason, record() needs to use this instead of using the loc! macro directly. -#[inline(always)] -pub fn loc<'a, P, Val>(parser: P) -> impl Parser<'a, Located> -where - P: Parser<'a, Val>, -{ - loc!(parser) -} - -/// For some reason, record_field() needs to use this instead of using the and! macro directly. -#[inline(always)] -pub fn and<'a, P1, P2, A, B>(p1: P1, p2: P2) -> impl Parser<'a, (A, B)> -where - P1: Parser<'a, A>, - P2: Parser<'a, B>, - P1: 'a, - P2: 'a, - A: 'a, - B: 'a, -{ - and!(p1, p2) -} - fn record_field<'a, P, S>(val_parser: P, min_indent: u16) -> impl Parser<'a, AssignedField<'a, S>> where P: Parser<'a, Located>,