mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-24 17:02:41 +00:00
Move IdentifiedFacetType to check (#8004)
`IdentifiedFacetType` is a concept that is only used by check. It does not appear in the semir output, unlike `DeclaredFacetType`s. `IdentifiedFacetType` is used in check to collapse named constraints together, building a single structure of requirements from a `DeclaredFacetType` and any referenced named constraints. This is used for operations like impl lookup, and building `FacetValue`s. The outputs of `IdentifiedFacetType` are now in an intermediate state, where they contain `IdentifiedWitness`es, and need to be processed before they are used. We'd like to build that into the API of `IdentifiedFacetType` so that their use is more robust. But the `IdentifiedWitnesses` need to be replaced by subst, which is a part of check, so we need to move `IdentifiedFacetType` to check in order to build the type on top of subst.
This commit is contained in:
1 parent
0546b48a7d
commit
fb7eff130d
28 files changed
+618
-607
No files matched your search
@@ -12,6 +12,7 @@
|
||||
#include "toolchain/check/facet_type.h"
|
||||
#include "toolchain/check/function.h"
|
||||
#include "toolchain/check/generic.h"
|
||||
#include "toolchain/check/identified_facet_type.h"
|
||||
#include "toolchain/check/impl_lookup.h"
|
||||
#include "toolchain/check/import_ref.h"
|
||||
#include "toolchain/check/inst.h"
|
||||
@@ -27,7 +28,6 @@
|
||||
#include "toolchain/check/type_structure.h"
|
||||
#include "toolchain/diagnostics/emitter.h"
|
||||
#include "toolchain/sem_ir/generic.h"
|
||||
#include "toolchain/sem_ir/identified_facet_type.h"
|
||||
#include "toolchain/sem_ir/ids.h"
|
||||
#include "toolchain/sem_ir/impl.h"
|
||||
#include "toolchain/sem_ir/inst.h"
|
||||
@@ -442,7 +442,7 @@ class SubstWithImplWitness : public SubstIdentifiedWitnessesCallbacks {
|
||||
auto AddImplWitnessForDeclaration(Context& context, SemIR::LocId loc_id,
|
||||
SemIR::LocId constraint_loc_id,
|
||||
const SemIR::Impl& impl,
|
||||
SemIR::IdentifiedFacetTypeId identified_id,
|
||||
IdentifiedFacetTypeId identified_id,
|
||||
SemIR::SpecificId self_specific_id)
|
||||
-> SemIR::InstId {
|
||||
const auto& identified = context.identified_facet_types().Get(identified_id);
|
||||
@@ -841,8 +841,7 @@ auto FinishImplWitness(Context& context, const SemIR::Impl& impl) -> void {
|
||||
auto CheckRequireDeclsSatisfied(Context& context, SemIR::LocId loc_id,
|
||||
SemIR::Impl& impl,
|
||||
SemIR::TypeInstId full_constraint_id,
|
||||
SemIR::IdentifiedFacetTypeId identified_id)
|
||||
-> void {
|
||||
IdentifiedFacetTypeId identified_id) -> void {
|
||||
if (impl.witness_id == SemIR::ErrorInst::InstId) {
|
||||
return;
|
||||
}
|
||||
@@ -1011,7 +1010,7 @@ auto CheckConstraintIsFacetType(Context& context, SemIR::LocId loc_id,
|
||||
auto CheckConstraintIsInterface(Context& context, SemIR::LocId loc_id,
|
||||
SemIR::InstId self_id,
|
||||
SemIR::TypeInstId full_constraint_id)
|
||||
-> SemIR::IdentifiedFacetTypeId {
|
||||
-> IdentifiedFacetTypeId {
|
||||
auto identified_id = RequireIdentifiedFacetType(
|
||||
context, SemIR::LocId(full_constraint_id),
|
||||
context.constant_values().Get(self_id),
|
||||
@@ -1023,7 +1022,7 @@ auto CheckConstraintIsInterface(Context& context, SemIR::LocId loc_id,
|
||||
builder.Attach(loc_id, ImplOfUnidentifiedFacetType, full_constraint_id);
|
||||
});
|
||||
if (!identified_id.has_value()) {
|
||||
return SemIR::IdentifiedFacetTypeId::None;
|
||||
return IdentifiedFacetTypeId::None;
|
||||
}
|
||||
const auto& identified = context.identified_facet_types().Get(identified_id);
|
||||
if (!identified.is_valid_impl_as_target()) {
|
||||
@@ -1031,7 +1030,7 @@ auto CheckConstraintIsInterface(Context& context, SemIR::LocId loc_id,
|
||||
"impl as {0} interfaces, expected 1", int);
|
||||
context.emitter().Emit(loc_id, ImplOfNotOneInterface,
|
||||
identified.num_interfaces_to_impl());
|
||||
return SemIR::IdentifiedFacetTypeId::None;
|
||||
return IdentifiedFacetTypeId::None;
|
||||
}
|
||||
return identified_id;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user