Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions toolchain/sem_ir/facet_type_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ auto AddCanonicalWitnessesBlock(File& sem_ir,
CARBON_FATAL("Unhandled inst: {0}", inst);
}
}
// This matches the sort order of IdentifiedFacetType::required_interfaces,
// which is the order of the witnesses returned from impl lookup, and is
// canonical order in which the witnesses must appear for a given facet type
// so that ImplWitnessAccess can find the appropriate witness.
llvm::sort(sortable, [](auto& lhs, auto& rhs) {
return ImplsLess(lhs.first, rhs.first);
});
Expand Down
8 changes: 5 additions & 3 deletions toolchain/sem_ir/facet_type_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,11 @@ inline auto CarbonHashValue(const FacetTypeInfo& value, uint64_t seed)
return static_cast<HashCode>(hasher);
}

// Given an array of witnesses, sorts them to match the FacetTypeInfo ordering
// and returns the resulting block ID. This assumes witnesses have already been
// deduplicated, because it's mainly for imports.
// Given an array of witnesses, sorts them to match the ordering of the specific
// interfaces in the IdentifiedFacetType that produced the witness set, which is
// the canonical witness order, and returns the resulting block ID. This assumes
// witnesses have already been deduplicated, and do not contain errors, because
// it's mainly for imports.
auto AddCanonicalWitnessesBlock(File& sem_ir,
llvm::SmallVector<InstId>& witnesses)
-> InstBlockId;
Expand Down
Loading