Expose ability names

This commit is contained in:
Ayaz Hafiz 2022-05-12 08:57:16 -04:00
parent 95395ffc5f
commit 1beb0551cb
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
3 changed files with 19 additions and 4 deletions

View file

@ -2,9 +2,9 @@ interface Encode
exposes exposes
[ [
Encoder, Encoder,
# Encoding, Encoding,
toEncoder, toEncoder,
# EncoderFormatting, EncoderFormatting,
u8, u16, u32, u64, u128, u8, u16, u32, u64, u128,
i8, i16, i32, i64, i128, i8, i16, i32, i64, i128,
f32, f64, dec, f32, f64, dec,

View file

@ -187,6 +187,13 @@ impl AbilitiesStore {
self.ability_members.get(&member) self.ability_members.get(&member)
} }
/// Iterator over all abilities and their members that this store knows about.
pub fn iter_abilities(&self) -> impl Iterator<Item = (Symbol, &[Symbol])> {
self.members_of_ability
.iter()
.map(|(k, v)| (*k, v.as_slice()))
}
/// Returns an iterator over pairs ((ability member, type), specialization) specifying that /// Returns an iterator over pairs ((ability member, type), specialization) specifying that
/// "ability member" has a "specialization" for type "type". /// "ability member" has a "specialization" for type "type".
pub fn iter_specializations( pub fn iter_specializations(

View file

@ -518,8 +518,16 @@ pub fn canonicalize_module_defs<'a>(
aliases.insert(symbol, alias); aliases.insert(symbol, alias);
} }
for member in scope.abilities_store.root_ability_members().keys() { for (ability, members) in scope
exposed_but_not_defined.remove(member); .abilities_store
.iter_abilities()
.filter(|(ab, _)| ab.module_id() == home)
{
exposed_but_not_defined.remove(&ability);
members.iter().for_each(|member| {
debug_assert!(member.module_id() == home);
exposed_but_not_defined.remove(member);
});
} }
// By this point, all exposed symbols should have been removed from // By this point, all exposed symbols should have been removed from