diff --git a/compiler/parse/src/ast.rs b/compiler/parse/src/ast.rs index dedde5f818..936842fc4a 100644 --- a/compiler/parse/src/ast.rs +++ b/compiler/parse/src/ast.rs @@ -273,7 +273,7 @@ pub enum Has<'a> { /// An ability demand is a value defining the ability; for example `hash : a -> U64 | a has Hash` /// for a `Hash` ability. #[derive(Debug, Clone, Copy, PartialEq)] -pub struct AbilityDemand<'a> { +pub struct AbilityMember<'a> { pub name: Loc>, pub typ: Loc>, } @@ -305,7 +305,7 @@ pub enum Def<'a> { Ability { header: TypeHeader<'a>, loc_has: Loc>, - demands: &'a [AbilityDemand<'a>], + members: &'a [AbilityMember<'a>], }, // TODO in canonicalization, check to see if there are any newlines after the diff --git a/compiler/parse/src/expr.rs b/compiler/parse/src/expr.rs index 1a5b8be89b..0663ee3496 100644 --- a/compiler/parse/src/expr.rs +++ b/compiler/parse/src/expr.rs @@ -1074,14 +1074,14 @@ fn finish_parsing_alias_or_opaque<'a>( mod ability { use super::*; use crate::{ - ast::{AbilityDemand, Spaceable, Spaced}, + ast::{AbilityMember, Spaceable, Spaced}, parser::EAbility, }; /// Parses a single ability demand line; see `parse_demand`. fn parse_demand_help<'a>( start_column: u32, - ) -> impl Parser<'a, AbilityDemand<'a>, EAbility<'a>> { + ) -> impl Parser<'a, AbilityMember<'a>, EAbility<'a>> { map!( and!( specialize(|_, pos| EAbility::DemandName(pos), loc!(lowercase_ident())), @@ -1099,7 +1099,7 @@ mod ability { ) ), |(name, typ): (Loc<&'a str>, Loc>)| { - AbilityDemand { + AbilityMember { name: name.map_owned(Spaced::Item), typ, } @@ -1117,7 +1117,7 @@ mod ability { /// This is basically the same as parsing a free-floating annotation, but with stricter rules. pub fn parse_demand<'a>( indent: IndentLevel, - ) -> impl Parser<'a, (u32, AbilityDemand<'a>), EAbility<'a>> { + ) -> impl Parser<'a, (u32, AbilityMember<'a>), EAbility<'a>> { move |arena, state: State<'a>| { let initial = state.clone(); diff --git a/compiler/parse/tests/snapshots/pass/ability_demand_signature_is_multiline.expr.result-ast b/compiler/parse/tests/snapshots/pass/ability_demand_signature_is_multiline.expr.result-ast index cd75525ef6..c5a2217c99 100644 --- a/compiler/parse/tests/snapshots/pass/ability_demand_signature_is_multiline.expr.result-ast +++ b/compiler/parse/tests/snapshots/pass/ability_demand_signature_is_multiline.expr.result-ast @@ -6,8 +6,8 @@ Defs( vars: [], }, loc_has: @5-8 Has, - demands: [ - AbilityDemand { + members: [ + AbilityMember { name: @11-15 SpaceBefore( "hash", [ diff --git a/compiler/parse/tests/snapshots/pass/ability_multi_line.expr.result-ast b/compiler/parse/tests/snapshots/pass/ability_multi_line.expr.result-ast index 0ad5d314f4..01dd4bbed5 100644 --- a/compiler/parse/tests/snapshots/pass/ability_multi_line.expr.result-ast +++ b/compiler/parse/tests/snapshots/pass/ability_multi_line.expr.result-ast @@ -6,8 +6,8 @@ Defs( vars: [], }, loc_has: @5-8 Has, - demands: [ - AbilityDemand { + members: [ + AbilityMember { name: @11-15 SpaceBefore( "hash", [ @@ -27,7 +27,7 @@ Defs( ), ), }, - AbilityDemand { + AbilityMember { name: @29-34 SpaceBefore( "hash2", [