mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 08:34:33 +00:00
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:
parent
b03e713b7f
commit
768121e431
3 changed files with 8 additions and 38 deletions
|
@ -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,18 +169,16 @@ 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 => {
|
||||
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));
|
||||
}
|
||||
Some(specialization) => {
|
||||
specialized_members.push(Loc::at(specialization.region, member));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !missing_members.is_empty() {
|
||||
|
@ -190,7 +187,6 @@ impl ObligationCache<'_> {
|
|||
Unfulfilled::Incomplete {
|
||||
typ,
|
||||
ability,
|
||||
specialized_members,
|
||||
missing_members,
|
||||
},
|
||||
);
|
||||
|
|
|
@ -232,7 +232,6 @@ fn report_unfulfilled_ability<'a>(
|
|||
Unfulfilled::Incomplete {
|
||||
typ,
|
||||
ability,
|
||||
specialized_members,
|
||||
missing_members,
|
||||
} => {
|
||||
debug_assert!(!missing_members.is_empty());
|
||||
|
@ -254,24 +253,6 @@ fn report_unfulfilled_ability<'a>(
|
|||
stack.push(alloc.region(lines.convert_region(member.region)));
|
||||
}
|
||||
|
||||
if !specialized_members.is_empty() {
|
||||
stack.push(alloc.concat([
|
||||
alloc.note(""),
|
||||
alloc.symbol_unqualified(typ),
|
||||
alloc.reflow(" specializes the following members of "),
|
||||
alloc.symbol_unqualified(ability),
|
||||
alloc.reflow(":"),
|
||||
]));
|
||||
|
||||
for spec in specialized_members {
|
||||
stack.push(alloc.concat([
|
||||
alloc.symbol_unqualified(spec.value),
|
||||
alloc.reflow(", specialized here:"),
|
||||
]));
|
||||
stack.push(alloc.region(lines.convert_region(spec.region)));
|
||||
}
|
||||
}
|
||||
|
||||
alloc.stack(stack)
|
||||
}
|
||||
Unfulfilled::Underivable {
|
||||
|
|
|
@ -9379,13 +9379,6 @@ All branches in an `if` must have the same type!
|
|||
|
||||
5│ le : a, a -> Bool | a has Eq
|
||||
^^
|
||||
|
||||
Note: `Id` specializes the following members of `Eq`:
|
||||
|
||||
`eq`, specialized here:
|
||||
|
||||
9│ eq = \@Id m, @Id n -> m == n
|
||||
^^
|
||||
"#
|
||||
),
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue