Skip to content

Commit e1fc972

Browse files
committed
yay
1 parent ec8e2d4 commit e1fc972

File tree

1 file changed

+28
-46
lines changed

1 file changed

+28
-46
lines changed

toolchain/check/type_completion.cpp

Lines changed: 28 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -76,58 +76,40 @@ static auto RequireCompleteFacetType(Context& context, SemIR::LocId loc_id,
7676
const SemIR::FacetType& facet_type,
7777
MakeDiagnosticBuilderFn diagnoser)
7878
-> bool {
79-
struct SpecificForRequires {
80-
SemIR::SpecificId specific_id;
81-
SemIR::RequireImplsBlockId requires_block_id;
82-
};
83-
llvm::SmallVector<SpecificForRequires> specifics;
84-
85-
llvm::SmallVector<SemIR::FacetTypeId> work = {facet_type.facet_type_id};
86-
while (!work.empty()) {
87-
auto next_facet_type_id = work.pop_back_val();
88-
const auto& facet_type_info = context.facet_types().Get(next_facet_type_id);
79+
const auto& facet_type_info =
80+
context.facet_types().Get(facet_type.facet_type_id);
8981

90-
for (auto extends : facet_type_info.extend_constraints) {
91-
auto interface_id = extends.interface_id;
92-
const auto& interface = context.interfaces().Get(interface_id);
93-
if (!interface.is_complete()) {
94-
if (diagnoser) {
95-
auto builder = diagnoser();
96-
NoteIncompleteInterface(context, interface_id, builder);
97-
builder.Emit();
98-
}
99-
return false;
100-
}
101-
if (interface.generic_id.has_value()) {
102-
specifics.push_back(
103-
{extends.specific_id, interface.require_impls_block_id});
82+
for (auto extends : facet_type_info.extend_constraints) {
83+
auto interface_id = extends.interface_id;
84+
const auto& interface = context.interfaces().Get(interface_id);
85+
if (!interface.is_complete()) {
86+
if (diagnoser) {
87+
auto builder = diagnoser();
88+
NoteIncompleteInterface(context, interface_id, builder);
89+
builder.Emit();
10490
}
91+
return false;
10592
}
106-
107-
for (auto extends : facet_type_info.extend_named_constraints) {
108-
auto named_constraint_id = extends.named_constraint_id;
109-
const auto& constraint =
110-
context.named_constraints().Get(named_constraint_id);
111-
if (!constraint.is_complete()) {
112-
if (diagnoser) {
113-
auto builder = diagnoser();
114-
NoteIncompleteNamedConstraint(context, named_constraint_id, builder);
115-
builder.Emit();
116-
}
117-
return false;
118-
}
119-
if (constraint.generic_id.has_value()) {
120-
specifics.push_back(
121-
{extends.specific_id, constraint.require_impls_block_id});
122-
}
93+
if (interface.generic_id.has_value()) {
94+
ResolveSpecificDefinition(context, loc_id, extends.specific_id);
12395
}
12496
}
12597

126-
// Specific definitions are resolved from the interfaces in the facet type
127-
// down, each require target depends on the specific referring to it being
128-
// resolved already.
129-
for (auto [specific_id, _] : specifics) {
130-
ResolveSpecificDefinition(context, loc_id, specific_id);
98+
for (auto extends : facet_type_info.extend_named_constraints) {
99+
auto named_constraint_id = extends.named_constraint_id;
100+
const auto& constraint =
101+
context.named_constraints().Get(named_constraint_id);
102+
if (!constraint.is_complete()) {
103+
if (diagnoser) {
104+
auto builder = diagnoser();
105+
NoteIncompleteNamedConstraint(context, named_constraint_id, builder);
106+
builder.Emit();
107+
}
108+
return false;
109+
}
110+
if (constraint.generic_id.has_value()) {
111+
ResolveSpecificDefinition(context, loc_id, extends.specific_id);
112+
}
131113
}
132114

133115
return true;

0 commit comments

Comments
 (0)