mirror of
https://github.com/roc-lang/roc.git
synced 2025-07-22 22:15:02 +00:00
ast::HasClause -> ast::ImplementsClause
This commit is contained in:
parent
64c34a5c6d
commit
ebbdae6c28
6 changed files with 19 additions and 19 deletions
|
@ -538,7 +538,7 @@ impl<'a> Defs<'a> {
|
|||
pub type AbilityName<'a> = Loc<TypeAnnotation<'a>>;
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
pub struct HasClause<'a> {
|
||||
pub struct ImplementsClause<'a> {
|
||||
pub var: Loc<Spaced<'a, &'a str>>,
|
||||
pub abilities: &'a [AbilityName<'a>],
|
||||
}
|
||||
|
@ -642,7 +642,7 @@ pub enum TypeAnnotation<'a> {
|
|||
Wildcard,
|
||||
|
||||
/// A "where" clause demanding abilities designated by a `|`, e.g. `a -> U64 | a has Hash`
|
||||
Where(&'a Loc<TypeAnnotation<'a>>, &'a [Loc<HasClause<'a>>]),
|
||||
Where(&'a Loc<TypeAnnotation<'a>>, &'a [Loc<ImplementsClause<'a>>]),
|
||||
|
||||
// We preserve this for the formatter; canonicalization ignores it.
|
||||
SpaceBefore(&'a TypeAnnotation<'a>, &'a [CommentOrNewline<'a>]),
|
||||
|
@ -1823,7 +1823,7 @@ impl<'a> Malformed for Tag<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Malformed for HasClause<'a> {
|
||||
impl<'a> Malformed for ImplementsClause<'a> {
|
||||
fn is_malformed(&self) -> bool {
|
||||
self.abilities.iter().any(|ability| ability.is_malformed())
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::ast::{
|
||||
AssignedField, CommentOrNewline, Expr, HasAbilities, HasAbility, HasClause, HasImpls, Pattern,
|
||||
Spaceable, Spaced, Tag, TypeAnnotation, TypeHeader,
|
||||
AssignedField, CommentOrNewline, Expr, HasAbilities, HasAbility, HasImpls, ImplementsClause,
|
||||
Pattern, Spaceable, Spaced, Tag, TypeAnnotation, TypeHeader,
|
||||
};
|
||||
use crate::blankspace::{
|
||||
space0_around_ee, space0_before_e, space0_before_optional_after, space0_e,
|
||||
|
@ -444,7 +444,7 @@ fn ability_chain<'a>() -> impl Parser<'a, Vec<'a, Loc<TypeAnnotation<'a>>>, ETyp
|
|||
)
|
||||
}
|
||||
|
||||
fn implements_clause<'a>() -> impl Parser<'a, Loc<HasClause<'a>>, EType<'a>> {
|
||||
fn implements_clause<'a>() -> impl Parser<'a, Loc<ImplementsClause<'a>>, EType<'a>> {
|
||||
map!(
|
||||
// Suppose we are trying to parse "a implements Hash"
|
||||
and!(
|
||||
|
@ -482,7 +482,7 @@ fn implements_clause<'a>() -> impl Parser<'a, Loc<HasClause<'a>>, EType<'a>> {
|
|||
&abilities.last().unwrap().region,
|
||||
);
|
||||
let region = Region::span_across(&var.region, &abilities_region);
|
||||
let implements_clause = HasClause {
|
||||
let implements_clause = ImplementsClause {
|
||||
var,
|
||||
abilities: abilities.into_bump_slice(),
|
||||
};
|
||||
|
@ -494,7 +494,7 @@ fn implements_clause<'a>() -> impl Parser<'a, Loc<HasClause<'a>>, EType<'a>> {
|
|||
/// Parse a chain of `implements` clauses, e.g. " | a implements Hash, b implements Eq".
|
||||
/// Returns the clauses and spaces before the starting "|", if there were any.
|
||||
fn implements_clause_chain<'a>(
|
||||
) -> impl Parser<'a, (&'a [CommentOrNewline<'a>], &'a [Loc<HasClause<'a>>]), EType<'a>> {
|
||||
) -> impl Parser<'a, (&'a [CommentOrNewline<'a>], &'a [Loc<ImplementsClause<'a>>]), EType<'a>> {
|
||||
move |arena, state: State<'a>, min_indent: u32| {
|
||||
let (_, (spaces_before, ()), state) =
|
||||
and!(space0_e(EType::TIndentStart), word1(b'|', EType::TWhereBar))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue