mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 03:42:17 +00:00
ast::HasClause -> ast::ImplementsClause
This commit is contained in:
parent
64c34a5c6d
commit
ebbdae6c28
6 changed files with 19 additions and 19 deletions
|
@ -1064,13 +1064,13 @@ fn canonicalize_has_clause(
|
|||
scope: &mut Scope,
|
||||
var_store: &mut VarStore,
|
||||
introduced_variables: &mut IntroducedVariables,
|
||||
clause: &Loc<roc_parse::ast::HasClause<'_>>,
|
||||
clause: &Loc<roc_parse::ast::ImplementsClause<'_>>,
|
||||
pending_abilities_in_scope: &PendingAbilitiesInScope,
|
||||
references: &mut VecSet<Symbol>,
|
||||
) -> Result<(), Type> {
|
||||
let Loc {
|
||||
region,
|
||||
value: roc_parse::ast::HasClause { var, abilities },
|
||||
value: roc_parse::ast::ImplementsClause { var, abilities },
|
||||
} = clause;
|
||||
let region = *region;
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ use crate::{
|
|||
Buf,
|
||||
};
|
||||
use roc_parse::ast::{
|
||||
AssignedField, Collection, Expr, ExtractSpaces, HasAbilities, HasAbility, HasClause, HasImpls,
|
||||
RecordBuilderField, Tag, TypeAnnotation, TypeHeader,
|
||||
AssignedField, Collection, Expr, ExtractSpaces, HasAbilities, HasAbility, HasImpls,
|
||||
ImplementsClause, RecordBuilderField, Tag, TypeAnnotation, TypeHeader,
|
||||
};
|
||||
use roc_parse::ident::UppercaseIdent;
|
||||
use roc_region::all::Loc;
|
||||
|
@ -645,7 +645,7 @@ impl<'a> Formattable for Tag<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Formattable for HasClause<'a> {
|
||||
impl<'a> Formattable for ImplementsClause<'a> {
|
||||
fn is_multiline(&self) -> bool {
|
||||
// No, always put abilities in a "has" clause on one line
|
||||
false
|
||||
|
|
|
@ -4,9 +4,9 @@ use roc_module::called_via::{BinOp, UnaryOp};
|
|||
use roc_parse::{
|
||||
ast::{
|
||||
AbilityMember, AssignedField, Collection, CommentOrNewline, Defs, Expr, HasAbilities,
|
||||
HasAbility, HasClause, HasImpls, Header, Implements, Module, Pattern, RecordBuilderField,
|
||||
Spaced, Spaces, StrLiteral, StrSegment, Tag, TypeAnnotation, TypeDef, TypeHeader, ValueDef,
|
||||
WhenBranch,
|
||||
HasAbility, HasImpls, Header, Implements, ImplementsClause, Module, Pattern,
|
||||
RecordBuilderField, Spaced, Spaces, StrLiteral, StrSegment, Tag, TypeAnnotation, TypeDef,
|
||||
TypeHeader, ValueDef, WhenBranch,
|
||||
},
|
||||
header::{
|
||||
AppHeader, ExposedName, HostedHeader, ImportsEntry, InterfaceHeader, KeywordItem,
|
||||
|
@ -862,9 +862,9 @@ impl<'a> RemoveSpaces<'a> for TypeAnnotation<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> RemoveSpaces<'a> for HasClause<'a> {
|
||||
impl<'a> RemoveSpaces<'a> for ImplementsClause<'a> {
|
||||
fn remove_spaces(&self, arena: &'a Bump) -> Self {
|
||||
HasClause {
|
||||
ImplementsClause {
|
||||
var: self.var.remove_spaces(arena),
|
||||
abilities: self.abilities.remove_spaces(arena),
|
||||
}
|
||||
|
|
|
@ -553,7 +553,7 @@ fn ability_member_type_to_docs(
|
|||
let has_clauses = has_clauses
|
||||
.iter()
|
||||
.map(|hc| {
|
||||
let ast::HasClause { var, abilities } = hc.value;
|
||||
let ast::ImplementsClause { var, abilities } = hc.value;
|
||||
(
|
||||
var.value.extract_spaces().item.to_string(),
|
||||
abilities
|
||||
|
|
|
@ -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