mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Make named constraint eval to a FacetType with itself in it (#6308)
This requires declared FacetTypes to hold NamedConstraintIds (along with a specific) that are named in an extend or impls requirement. We add support to stringify and formatter to display the named constraints in the facet type, and special case when a facet type contains a single extend named constraint, like we did for a single extend interface. This means that `RequireIndentifiedFacetType` can now fail, if the facet type contains a forward-declared named constraint. Add the appropriate diagnostics for each call to this function, and note the ones that should change to `RequireCompleteFacetType` in the future with TODOs. We also add tests for using facet types that can or can't be identified, or completed, with named constraints in them.
This commit is contained in:
@@ -296,7 +296,16 @@ auto CheckConstraintIsInterface(Context& context, SemIR::InstId impl_decl_id,
|
||||
return SemIR::SpecificInterface::None;
|
||||
}
|
||||
|
||||
auto identified_id = RequireIdentifiedFacetType(context, *facet_type);
|
||||
auto identified_id = RequireIdentifiedFacetType(context, *facet_type, [&] {
|
||||
CARBON_DIAGNOSTIC(ImplOfUnidentifiedFacetType, Error,
|
||||
"facet type {0} cannot be identified in `impl as`",
|
||||
InstIdAsType);
|
||||
return context.emitter().Build(impl_decl_id, ImplOfUnidentifiedFacetType,
|
||||
constraint_id);
|
||||
});
|
||||
if (!identified_id.has_value()) {
|
||||
return SemIR::SpecificInterface::None;
|
||||
}
|
||||
const auto& identified = context.identified_facet_types().Get(identified_id);
|
||||
if (!identified.is_valid_impl_as_target()) {
|
||||
CARBON_DIAGNOSTIC(ImplOfNotOneInterface, Error,
|
||||
|
||||
Reference in New Issue
Block a user