mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 21:30:12 +01:00
Document the relationship of AddCanonicalWitnessesBlock to IdentifiedFacetType (#6461)
The ordering of FacetTypeInfo is not important to the canonical ordering of witnesses. The order that must match is that of the IdentifiedFacetType::required_interfaces.
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user