Don't allocate for missing or existing members by default

- Missing members are zero in the happy case
- Existing members will always be populated in the happy case, but I
  don't think they improve the error message, so just get rid of it.
This commit is contained in:
Ayaz Hafiz 2022-05-19 18:25:42 -04:00
parent b03e713b7f
commit 768121e431
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
3 changed files with 8 additions and 38 deletions

View file

@ -36,7 +36,6 @@ pub enum Unfulfilled {
Incomplete {
typ: Symbol,
ability: Symbol,
specialized_members: Vec<Loc<Symbol>>,
missing_members: Vec<Loc<Symbol>>,
},
/// Cannot derive implementation of an ability for a type.
@ -170,17 +169,15 @@ impl ObligationCache<'_> {
match typ {
Obligated::Opaque(typ) => {
let members_of_ability = self.abilities_store.members_of_ability(ability).unwrap();
let mut specialized_members = Vec::with_capacity(members_of_ability.len());
let mut missing_members = Vec::with_capacity(members_of_ability.len());
let mut missing_members = Vec::new();
for &member in members_of_ability {
match self.abilities_store.get_specialization(member, typ) {
None => {
let root_data = self.abilities_store.member_def(member).unwrap();
missing_members.push(Loc::at(root_data.region, member));
}
Some(specialization) => {
specialized_members.push(Loc::at(specialization.region, member));
}
if self
.abilities_store
.get_specialization(member, typ)
.is_none()
{
let root_data = self.abilities_store.member_def(member).unwrap();
missing_members.push(Loc::at(root_data.region, member));
}
}
@ -190,7 +187,6 @@ impl ObligationCache<'_> {
Unfulfilled::Incomplete {
typ,
ability,
specialized_members,
missing_members,
},
);