mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-18 05:10:28 +00:00
Get equality requirements from the IdentifiedFacetType in impl lookup (#7944)
Instead of only getting rewrite/equality requirements from the declared facet type, impl lookup now uses the full IdentifiedFacetType of the query's constraint to get rewrite/equality requirements from named constraints as well.
This commit is contained in:
1 parent
51e2c76a8e
commit
5402b4c56e
7 files changed
+163
-147
No files matched your search
+95
-114
@@ -222,31 +222,6 @@ static auto FindAndDiagnoseImplLookupCycle(
|
||||
return false;
|
||||
}
|
||||
|
||||
// Gets the set of `SpecificInterface`s that are required by a facet type
|
||||
// (as a constant value), and any special requirements.
|
||||
static auto GetRequiredImplsFromConstraint(
|
||||
Context& context, SemIR::LocId loc_id,
|
||||
SemIR::ConstantId query_self_const_id,
|
||||
SemIR::ConstantId query_facet_type_const_id, bool diagnose)
|
||||
-> std::optional<llvm::ArrayRef<SemIR::IdentifiedFacetType::RequiredImpl>> {
|
||||
auto identified_id = RequireIdentifiedFacetType(
|
||||
context, loc_id, query_self_const_id,
|
||||
context.types().GetTypeIdForTypeConstantId(query_facet_type_const_id),
|
||||
[&](auto& builder) {
|
||||
CARBON_DIAGNOSTIC(ImplLookupInUnidentifiedFacetType, Context,
|
||||
"facet type {0} can not be identified",
|
||||
SemIR::TypeId);
|
||||
builder.Context(loc_id, ImplLookupInUnidentifiedFacetType,
|
||||
context.types().GetTypeIdForTypeConstantId(
|
||||
query_facet_type_const_id));
|
||||
},
|
||||
diagnose);
|
||||
if (!identified_id.has_value()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return context.identified_facet_types().Get(identified_id).required_impls();
|
||||
}
|
||||
|
||||
static auto TreatImplAsFinal(Context& context, const SemIR::Impl& impl)
|
||||
-> bool {
|
||||
// Lookups for the impl inside its own definition treat the impl as final.
|
||||
@@ -493,91 +468,42 @@ static auto CollectFacetWitnessSources(
|
||||
return witnesses;
|
||||
}
|
||||
|
||||
// Given a query `orig_inst_self` and `orig_interface`, try find a matching
|
||||
// witness from impl lookup to use for the query.
|
||||
static auto TryFindMatchingWitnessFromImplLookup(
|
||||
llvm::ArrayRef<SemIR::IdentifiedFacetType::RequiredImpl> req_impls,
|
||||
llvm::ArrayRef<SemIR::InstId> found_witness_inst_ids,
|
||||
SemIR::ConstantId orig_const_self, SemIR::SpecificInterface orig_interface)
|
||||
-> SemIR::InstId {
|
||||
for (auto [req_impl, found_witness_inst_id] :
|
||||
llvm::zip_equal(req_impls, found_witness_inst_ids)) {
|
||||
auto [req_const_self, req_interface] = req_impl;
|
||||
if (req_const_self == orig_const_self && req_interface == orig_interface) {
|
||||
return found_witness_inst_id;
|
||||
}
|
||||
}
|
||||
return SemIR::InstId::None;
|
||||
}
|
||||
class SubstMatchingWitnessesFromImplLookup
|
||||
: public SubstIdentifiedWitnessesCallbacks {
|
||||
public:
|
||||
explicit SubstMatchingWitnessesFromImplLookup(
|
||||
Context* context,
|
||||
llvm::ArrayRef<SemIR::IdentifiedFacetType::RequiredImpl> req_impls,
|
||||
llvm::ArrayRef<SemIR::InstId> found_witness_inst_ids)
|
||||
: SubstIdentifiedWitnessesCallbacks(context),
|
||||
req_impls_(req_impls),
|
||||
found_witness_inst_ids_(found_witness_inst_ids) {}
|
||||
|
||||
static auto VerifyQueryFacetTypeConstraints(
|
||||
Context& context, SemIR::LocId loc_id,
|
||||
SemIR::ConstantId query_self_const_id,
|
||||
SemIR::ConstantId query_facet_type_const_id,
|
||||
llvm::ArrayRef<SemIR::IdentifiedFacetType::RequiredImpl> req_impls,
|
||||
llvm::ArrayRef<SemIR::InstId> witness_inst_ids) -> bool {
|
||||
// TODO: Get the rewrites and equality constraints from the
|
||||
// IdentifiedFacetType so that we also find and verify requirements from named
|
||||
// constraints.
|
||||
const auto& declared_facet_type = context.declared_facet_types().Get(
|
||||
context.constant_values()
|
||||
.GetInstAs<SemIR::FacetType>(query_facet_type_const_id)
|
||||
.declared_facet_type_id);
|
||||
|
||||
if (!declared_facet_type.rewrite_constraints.empty()) {
|
||||
auto rebuild = [&](SemIR::Inst new_inst) -> SemIR::InstId {
|
||||
// When rebuilding a witness where `.Self` was replaced, use a witness we
|
||||
// found in impl lookup instead of performing impl lookup again.
|
||||
if (auto lookup = new_inst.TryAs<SemIR::LookupImplWitness>()) {
|
||||
auto witness = TryFindMatchingWitnessFromImplLookup(
|
||||
req_impls, witness_inst_ids,
|
||||
context.constant_values().Get(lookup->query_self_inst_id),
|
||||
context.specific_interfaces().Get(
|
||||
lookup->query_specific_interface_id));
|
||||
if (witness.has_value()) {
|
||||
return witness;
|
||||
}
|
||||
}
|
||||
|
||||
return SemIR::InstId::None;
|
||||
};
|
||||
|
||||
for (const auto& rewrite : declared_facet_type.rewrite_constraints) {
|
||||
// Replace `.Self` in rewrite constraints with the query self in order to
|
||||
// find the provided values of rewrite constraints from the query. This
|
||||
// includes replacing `.Self` in LookupImplWitness instructions.
|
||||
//
|
||||
// When we have found a witness in impl lookup for the query in a
|
||||
// LookupImplWitness insts, we need to use that witness directly instead
|
||||
// of rebuilding (and reevaluating) the LookupImplWitness which will
|
||||
// execute another impl lookup.
|
||||
|
||||
auto lhs_id = context.constant_values().GetInstId(SubstPeriodSelf(
|
||||
context, loc_id, context.constant_values().Get(rewrite.lhs_id),
|
||||
query_self_const_id, rebuild));
|
||||
auto rhs_id = context.constant_values().GetInstId(SubstPeriodSelf(
|
||||
context, loc_id, context.constant_values().Get(rewrite.rhs_id),
|
||||
query_self_const_id, rebuild));
|
||||
|
||||
if (lhs_id != rhs_id) {
|
||||
// TODO: Provide a diagnostic note and location for which rewrite
|
||||
// constraint was not satisfied, if a diagnostic is going to be
|
||||
// displayed for the LookupImplWitness() failure. This may require
|
||||
// plumbing through a callback that lets us add a Note to another
|
||||
// diagnostic.
|
||||
return false;
|
||||
auto ReplaceIdentified(SemIR::IdentifiedWitness witness)
|
||||
-> SemIR::InstId override {
|
||||
for (auto [req_impl, found_witness_inst_id] :
|
||||
llvm::zip_equal(req_impls_, found_witness_inst_ids_)) {
|
||||
auto [req_const_self, req_interface] = req_impl;
|
||||
if (req_const_self ==
|
||||
context().constant_values().Get(witness.query_self_inst_id) &&
|
||||
req_interface == context().specific_interfaces().Get(
|
||||
witness.query_specific_interface_id)) {
|
||||
return found_witness_inst_id;
|
||||
}
|
||||
}
|
||||
return SemIR::InstId::None;
|
||||
}
|
||||
|
||||
// TODO: Validate that the witnesses satisfy the other requirements in the
|
||||
// `declared_facet_type`.
|
||||
if (declared_facet_type.other_requirements) {
|
||||
return false;
|
||||
auto ReplaceImplSelfWitness(SemIR::ImplSelfWitness /*witness*/)
|
||||
-> SemIR::InstId override {
|
||||
// ImplSelfWitnesses should only appear in impl decls and are all replaced.
|
||||
CARBON_FATAL();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
private:
|
||||
llvm::ArrayRef<SemIR::IdentifiedFacetType::RequiredImpl> req_impls_;
|
||||
llvm::ArrayRef<SemIR::InstId> found_witness_inst_ids_;
|
||||
};
|
||||
|
||||
// Returns whether the query is concrete, it is false if the self type or
|
||||
// interface specifics have a symbolic dependency.
|
||||
@@ -930,19 +856,40 @@ auto LookupImplWitness(Context& context, SemIR::LocId loc_id,
|
||||
query_facet_type_const_id));
|
||||
}
|
||||
|
||||
auto req_impls_from_constraint =
|
||||
GetRequiredImplsFromConstraint(context, loc_id, query_self_const_id,
|
||||
query_facet_type_const_id, diagnose);
|
||||
if (!req_impls_from_constraint.has_value()) {
|
||||
// This IdentifiedFacetType holds all the requirements that the impl lookup is
|
||||
// trying to satisfy. On success, each `X impls Y` requirement in here will
|
||||
// result in a witness being returned that provides the `impls` relationship.
|
||||
// Each equivalent requirement must be verified to be true in order to
|
||||
// succeed. Since we're doing impl lookup and not defining an `impl` witness,
|
||||
// we treat all rewrite requirements as equivalent requirements.
|
||||
auto required_identified_id = RequireIdentifiedFacetType(
|
||||
context, loc_id, query_self_const_id,
|
||||
context.types().GetTypeIdForTypeConstantId(query_facet_type_const_id),
|
||||
[&](auto& builder) {
|
||||
CARBON_DIAGNOSTIC(ImplLookupInUnidentifiedFacetType, Context,
|
||||
"facet type {0} can not be identified",
|
||||
SemIR::TypeId);
|
||||
builder.Context(loc_id, ImplLookupInUnidentifiedFacetType,
|
||||
context.types().GetTypeIdForTypeConstantId(
|
||||
query_facet_type_const_id));
|
||||
},
|
||||
diagnose);
|
||||
if (!required_identified_id.has_value()) {
|
||||
return SemIR::InstBlockIdOrError::MakeError();
|
||||
}
|
||||
if (req_impls_from_constraint->empty()) {
|
||||
|
||||
const auto& required_identified =
|
||||
context.identified_facet_types().Get(required_identified_id);
|
||||
if (required_identified.required_impls().empty()) {
|
||||
CARBON_CHECK(required_identified.equivalents().empty());
|
||||
CARBON_CHECK(required_identified.rewrites().empty());
|
||||
// Nothing to do, return an empty success result.
|
||||
return SemIR::InstBlockId::Empty;
|
||||
}
|
||||
// These RequiredImpls have IdentifiedWitnesses in them initially. We will
|
||||
// replace those with real witnesses as we process them.
|
||||
llvm::SmallVector<SemIR::IdentifiedFacetType::RequiredImpl> req_impls(
|
||||
*req_impls_from_constraint);
|
||||
required_identified.required_impls());
|
||||
|
||||
// Find all the facets in the query and their witnesses.
|
||||
auto witness_sources = CollectFacetWitnessSources(
|
||||
@@ -1038,14 +985,48 @@ auto LookupImplWitness(Context& context, SemIR::LocId loc_id,
|
||||
return SemIR::InstBlockId::None;
|
||||
}
|
||||
|
||||
// Verify rewrite constraints in the query constraint are satisfied after
|
||||
// applying the rewrites from the found witnesses.
|
||||
// Verify all equivalent requirements in the query constraint are satisfied.
|
||||
// We apply the witnesses that we've found to those requirements in order to
|
||||
// compare them without causing redundant and cyclic impl lookups.
|
||||
//
|
||||
// Note that the `req_impls` have all had their IdentifiedWitnesses replaced
|
||||
// by real witnesses by this point.
|
||||
if (!VerifyQueryFacetTypeConstraints(context, loc_id, query_self_const_id,
|
||||
query_facet_type_const_id, req_impls,
|
||||
result_witness_ids)) {
|
||||
SubstMatchingWitnessesFromImplLookup subst_witnesses_callbacks(
|
||||
&context, req_impls, result_witness_ids);
|
||||
for (auto equiv : required_identified.equivalents()) {
|
||||
equiv = SubstIdentifiedWitnesses(context, loc_id, equiv,
|
||||
subst_witnesses_callbacks);
|
||||
if (equiv.lhs != equiv.rhs) {
|
||||
// TODO: Provide a diagnostic note and location for which rewrite
|
||||
// constraint was not satisfied, if a diagnostic is going to be
|
||||
// displayed for the LookupImplWitness() failure. This may require
|
||||
// plumbing through a callback that lets us add a Note to another
|
||||
// diagnostic.
|
||||
return SemIR::InstBlockId::None;
|
||||
}
|
||||
}
|
||||
for (auto rewrite : required_identified.rewrites()) {
|
||||
// Rewrites are treated as equivalent requirements in impl lookup.
|
||||
SemIR::IdentifiedFacetType::Equivalent equiv = {.lhs = rewrite.lhs,
|
||||
.rhs = rewrite.rhs};
|
||||
equiv = SubstIdentifiedWitnesses(context, loc_id, equiv,
|
||||
subst_witnesses_callbacks);
|
||||
if (equiv.lhs != equiv.rhs) {
|
||||
// TODO: Provide a diagnostic note and location for which rewrite
|
||||
// constraint was not satisfied, if a diagnostic is going to be
|
||||
// displayed for the LookupImplWitness() failure. This may require
|
||||
// plumbing through a callback that lets us add a Note to another
|
||||
// diagnostic.
|
||||
return SemIR::InstBlockId::None;
|
||||
}
|
||||
}
|
||||
// TODO: Collect equality constraints into the IdentifiedFacetType. Then this
|
||||
// goes away.
|
||||
if (context.declared_facet_types()
|
||||
.Get(context.constant_values()
|
||||
.GetInstAs<SemIR::FacetType>(query_facet_type_const_id)
|
||||
.declared_facet_type_id)
|
||||
.other_requirements) {
|
||||
return SemIR::InstBlockId::None;
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -193,7 +193,7 @@ interface Z {
|
||||
}
|
||||
}
|
||||
|
||||
// --- todo_fail_impl_mismatch_named_constraint_rewrites.carbon
|
||||
// --- fail_impl_mismatch_named_constraint_rewrites.carbon
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
interface Z { let Z0: type; }
|
||||
@@ -206,6 +206,9 @@ fn G() {
|
||||
class C {}
|
||||
// .Z0 has the wrong type for M.
|
||||
impl C as Z where .Z0 = () {}
|
||||
// TODO: Converting C to M should fail since the rewrite constraints are incompatible.
|
||||
// CHECK:STDERR: fail_impl_mismatch_named_constraint_rewrites.carbon:[[@LINE+4]]:3: error: cannot convert type `C` into type implementing `M` [ConversionFailureTypeToFacet]
|
||||
// CHECK:STDERR: C as M;
|
||||
// CHECK:STDERR: ^~~~~~
|
||||
// CHECK:STDERR:
|
||||
C as M;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ fn G(generic T: I where .Self impls N) {
|
||||
F(T);
|
||||
}
|
||||
|
||||
// --- todo_fail_where_impls_tests_associated_constant_of_generic_type_non_final_impl.carbon
|
||||
// --- fail_where_impls_tests_associated_constant_of_generic_type_non_final_impl.carbon
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
class C(U: type) {}
|
||||
@@ -78,8 +78,13 @@ fn G(generic T: L) {
|
||||
// `(C(T) as M).M0` concretely, so we don't know that it is `{}` and we can't
|
||||
// convert assuming it is.
|
||||
//
|
||||
// TODO: This should fail. The rewrite constraint from `M0IsStruct` is not
|
||||
// being checked.
|
||||
// CHECK:STDERR: fail_where_impls_tests_associated_constant_of_generic_type_non_final_impl.carbon:[[@LINE+7]]:3: error: cannot convert type `T` that implements `L` into type implementing `type where C(.Self) impls M0IsStruct` [ConversionFailureFacetToFacet]
|
||||
// CHECK:STDERR: F(T);
|
||||
// CHECK:STDERR: ^~~~
|
||||
// CHECK:STDERR: fail_where_impls_tests_associated_constant_of_generic_type_non_final_impl.carbon:[[@LINE-10]]:21: note: initializing generic parameter `U` declared here [InitializingGenericParam]
|
||||
// CHECK:STDERR: fn F(unused generic U: type where C(.Self) impls M0IsStruct) {}
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
F(T);
|
||||
}
|
||||
|
||||
@@ -106,7 +111,7 @@ fn G(generic T: L) {
|
||||
F(T);
|
||||
}
|
||||
|
||||
// --- todo_fail_where_impls_tests_associated_constant_of_generic_type_type_differs.carbon
|
||||
// --- fail_where_impls_tests_associated_constant_of_generic_type_type_differs.carbon
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
class C(U: type) {}
|
||||
@@ -128,11 +133,17 @@ fn F(unused generic U: type where C(.Self) impls M0IsStruct) {}
|
||||
fn G(generic T: L) {
|
||||
// F requires .M0 = {}, but the final impl provides .M0 = ().
|
||||
//
|
||||
// TODO: This should fail.
|
||||
// CHECK:STDERR: fail_where_impls_tests_associated_constant_of_generic_type_type_differs.carbon:[[@LINE+7]]:3: error: cannot convert type `T` that implements `L` into type implementing `type where C(.Self) impls M0IsStruct` [ConversionFailureFacetToFacet]
|
||||
// CHECK:STDERR: F(T);
|
||||
// CHECK:STDERR: ^~~~
|
||||
// CHECK:STDERR: fail_where_impls_tests_associated_constant_of_generic_type_type_differs.carbon:[[@LINE-8]]:21: note: initializing generic parameter `U` declared here [InitializingGenericParam]
|
||||
// CHECK:STDERR: fn F(unused generic U: type where C(.Self) impls M0IsStruct) {}
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
F(T);
|
||||
}
|
||||
|
||||
// --- todo_fail_where_impls_tests_associated_constant_of_generic_interface_non_final_impl.carbon
|
||||
// --- fail_where_impls_tests_associated_constant_of_generic_interface_non_final_impl.carbon
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
class C {}
|
||||
@@ -156,7 +167,13 @@ fn G(generic T: L) {
|
||||
// `(C as M(T)).M0` concretely, so we don't know that it is `{}` and we can't
|
||||
// convert assuming it is.
|
||||
//
|
||||
// TODO: This should fail.
|
||||
// CHECK:STDERR: fail_where_impls_tests_associated_constant_of_generic_interface_non_final_impl.carbon:[[@LINE+7]]:3: error: cannot convert type `T` that implements `L` into type implementing `type where C impls M0IsStruct(.Self)` [ConversionFailureFacetToFacet]
|
||||
// CHECK:STDERR: F(T);
|
||||
// CHECK:STDERR: ^~~~
|
||||
// CHECK:STDERR: fail_where_impls_tests_associated_constant_of_generic_interface_non_final_impl.carbon:[[@LINE-10]]:21: note: initializing generic parameter `U` declared here [InitializingGenericParam]
|
||||
// CHECK:STDERR: fn F(unused generic U: type where C impls M0IsStruct(.Self)) {}
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
F(T);
|
||||
}
|
||||
|
||||
@@ -183,7 +200,7 @@ fn G(generic T: L) {
|
||||
F(T);
|
||||
}
|
||||
|
||||
// --- todo_fail_where_impls_tests_associated_constant_of_generic_interface_type_differs.carbon
|
||||
// --- fail_where_impls_tests_associated_constant_of_generic_interface_type_differs.carbon
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
class C {}
|
||||
@@ -206,6 +223,13 @@ fn G(generic T: L) {
|
||||
// F requires that .M0 = {} but the final impl provides that .M0 = ().
|
||||
//
|
||||
// TODO: This should fail.
|
||||
// CHECK:STDERR: fail_where_impls_tests_associated_constant_of_generic_interface_type_differs.carbon:[[@LINE+7]]:3: error: cannot convert type `T` that implements `L` into type implementing `type where C impls M0IsStruct(.Self)` [ConversionFailureFacetToFacet]
|
||||
// CHECK:STDERR: F(T);
|
||||
// CHECK:STDERR: ^~~~
|
||||
// CHECK:STDERR: fail_where_impls_tests_associated_constant_of_generic_interface_type_differs.carbon:[[@LINE-9]]:21: note: initializing generic parameter `U` declared here [InitializingGenericParam]
|
||||
// CHECK:STDERR: fn F(unused generic U: type where C impls M0IsStruct(.Self)) {}
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
F(T);
|
||||
}
|
||||
|
||||
|
||||
@@ -1178,7 +1178,7 @@ fn G(generic T: I where .X = NI({}), generic U: J where .Y = ()) {
|
||||
F(T, U);
|
||||
}
|
||||
|
||||
// --- todo_fail_nested_facet_type_used_as_root_facet_type_differs_in_rewrite_callee_access.carbon
|
||||
// --- fail_nested_facet_type_used_as_root_facet_type_differs_in_rewrite_callee_access.carbon
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
interface I {
|
||||
@@ -1196,7 +1196,13 @@ fn G(generic T: I where .X = NI({}), generic U: I where .Y = ()) {
|
||||
// The caller's `U` has type `I where .Y = ()` but the callee wants something
|
||||
// of type `I where .Y = {}`.
|
||||
//
|
||||
// TODO: This should fail.
|
||||
// CHECK:STDERR: fail_nested_facet_type_used_as_root_facet_type_differs_in_rewrite_callee_access.carbon:[[@LINE+7]]:3: error: cannot convert type `U` that implements `I where .(I.Y) = ()` into type implementing `NI({})` [ConversionFailureFacetToFacet]
|
||||
// CHECK:STDERR: F(T, U);
|
||||
// CHECK:STDERR: ^~~~~~~
|
||||
// CHECK:STDERR: fail_nested_facet_type_used_as_root_facet_type_differs_in_rewrite_callee_access.carbon:[[@LINE-9]]:53: note: initializing generic parameter `U` declared here [InitializingGenericParam]
|
||||
// CHECK:STDERR: fn F(generic T: I where .X = NI({}), unused generic U: T.X) {}
|
||||
// CHECK:STDERR: ^~~~~~
|
||||
// CHECK:STDERR:
|
||||
F(T, U);
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -994,7 +994,6 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd,
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.NewCursor.f70: %T.as_type.as.Iterate.impl.NewCursor.type.290 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.Next.type.79e: type = fn_type @T.as_type.as.Iterate.impl.Next, @T.as_type.as.Iterate.impl(%facet_value.383) [concrete]
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.Next.573: %T.as_type.as.Iterate.impl.Next.type.79e = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %Iterate.facet.2b0: %Iterate.type = facet_value %MutableRange, (%Iterate.impl_witness.a35) [concrete]
|
||||
// CHECK:STDOUT: %facet_value.b06: %Iterate_where.type.8d9 = facet_value %MutableRange, (%Iterate.impl_witness.a35) [concrete]
|
||||
// CHECK:STDOUT: %r.param_patt.c79: %pattern_type.e63 = value_param_pattern [concrete]
|
||||
// CHECK:STDOUT: %r.patt.94f: %pattern_type.e63 = wrapper_binding_pattern r, %r.param_patt.c79 [concrete]
|
||||
@@ -1037,10 +1036,10 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd,
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.NewCursor.356: %T.as_type.as.Iterate.impl.NewCursor.type.5c1 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.Next.type.f76: type = fn_type @T.as_type.as.Iterate.impl.Next, @T.as_type.as.Iterate.impl(%facet_value.15e) [concrete]
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.Next.259: %T.as_type.as.Iterate.impl.Next.type.f76 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %Iterate.facet.1c8: %Iterate.type = facet_value %ConstRange, (%Iterate.impl_witness.39d) [concrete]
|
||||
// CHECK:STDOUT: %facet_value.3df: %Iterate_where.type.8d9 = facet_value %ConstRange, (%Iterate.impl_witness.39d) [concrete]
|
||||
// CHECK:STDOUT: %r.param_patt.83e: %pattern_type.0ba = value_param_pattern [concrete]
|
||||
// CHECK:STDOUT: %r.patt.c21: %pattern_type.0ba = wrapper_binding_pattern r, %r.param_patt.83e [concrete]
|
||||
// CHECK:STDOUT: %Iterate.facet.2b0: %Iterate.type = facet_value %MutableRange, (%Iterate.impl_witness.a35) [concrete]
|
||||
// CHECK:STDOUT: %Iterate.WithSelf.NewCursor.type.ca0: type = fn_type @Iterate.WithSelf.NewCursor, @Iterate.WithSelf(%Iterate.facet.2b0) [concrete]
|
||||
// CHECK:STDOUT: %Iterate.WithSelf.Next.type.8bc: type = fn_type @Iterate.WithSelf.Next, @Iterate.WithSelf(%Iterate.facet.2b0) [concrete]
|
||||
// CHECK:STDOUT: %.d4c: type = fn_type_with_self_type %Iterate.WithSelf.NewCursor.type.ca0, %Iterate.facet.2b0 [concrete]
|
||||
@@ -1049,6 +1048,7 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd,
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.Next.specific_fn.7ef: <specific function> = specific_function %T.as_type.as.Iterate.impl.Next.573, @T.as_type.as.Iterate.impl.Next(%facet_value.383) [concrete]
|
||||
// CHECK:STDOUT: %Destroy.WithSelf.SelfDestruct.type.d1f: type = fn_type @Destroy.WithSelf.SelfDestruct.1, @Destroy.WithSelf(%Destroy.facet.0fe) [concrete]
|
||||
// CHECK:STDOUT: %.0dc: type = fn_type_with_self_type %Destroy.WithSelf.SelfDestruct.type.d1f, %Destroy.facet.0fe [concrete]
|
||||
// CHECK:STDOUT: %Iterate.facet.1c8: %Iterate.type = facet_value %ConstRange, (%Iterate.impl_witness.39d) [concrete]
|
||||
// CHECK:STDOUT: %Iterate.WithSelf.NewCursor.type.97c: type = fn_type @Iterate.WithSelf.NewCursor, @Iterate.WithSelf(%Iterate.facet.1c8) [concrete]
|
||||
// CHECK:STDOUT: %Iterate.WithSelf.Next.type.1c9: type = fn_type @Iterate.WithSelf.Next, @Iterate.WithSelf(%Iterate.facet.1c8) [concrete]
|
||||
// CHECK:STDOUT: %.582: type = fn_type_with_self_type %Iterate.WithSelf.NewCursor.type.97c, %Iterate.facet.1c8 [concrete]
|
||||
@@ -1819,7 +1819,6 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd,
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.NewCursor.a7b: %T.as_type.as.Iterate.impl.NewCursor.type.899 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.Next.type.355: type = fn_type @T.as_type.as.Iterate.impl.Next, @T.as_type.as.Iterate.impl(%facet_value.4bb) [concrete]
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.Next.8ce: %T.as_type.as.Iterate.impl.Next.type.355 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %Iterate.facet.758: %Iterate.type = facet_value %DiffMutableRange, (%Iterate.impl_witness.606) [concrete]
|
||||
// CHECK:STDOUT: %facet_value.2c1: %Iterate_where.type.b96 = facet_value %DiffMutableRange, (%Iterate.impl_witness.606) [concrete]
|
||||
// CHECK:STDOUT: %r.patt.5fe: %pattern_type.611 = ref_binding_pattern r [concrete]
|
||||
// CHECK:STDOUT: %r.param_patt.a4b: %pattern_type.611 = var_param_pattern %r.patt.5fe [concrete]
|
||||
@@ -1870,10 +1869,10 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd,
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.NewCursor.3cd: %T.as_type.as.Iterate.impl.NewCursor.type.4f6 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.Next.type.885: type = fn_type @T.as_type.as.Iterate.impl.Next, @T.as_type.as.Iterate.impl(%facet_value.683) [concrete]
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.Next.d18: %T.as_type.as.Iterate.impl.Next.type.885 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %Iterate.facet.930: %Iterate.type = facet_value %DiffConstRange, (%Iterate.impl_witness.9b4) [concrete]
|
||||
// CHECK:STDOUT: %facet_value.1fc: %Iterate_where.type.b96 = facet_value %DiffConstRange, (%Iterate.impl_witness.9b4) [concrete]
|
||||
// CHECK:STDOUT: %r.patt.9c0: %pattern_type.7dd = ref_binding_pattern r [concrete]
|
||||
// CHECK:STDOUT: %r.param_patt.992: %pattern_type.7dd = var_param_pattern %r.patt.9c0 [concrete]
|
||||
// CHECK:STDOUT: %Iterate.facet.758: %Iterate.type = facet_value %DiffMutableRange, (%Iterate.impl_witness.606) [concrete]
|
||||
// CHECK:STDOUT: %Iterate.WithSelf.NewCursor.type.49d: type = fn_type @Iterate.WithSelf.NewCursor, @Iterate.WithSelf(%Iterate.facet.758) [concrete]
|
||||
// CHECK:STDOUT: %Iterate.WithSelf.Next.type.1f8: type = fn_type @Iterate.WithSelf.Next, @Iterate.WithSelf(%Iterate.facet.758) [concrete]
|
||||
// CHECK:STDOUT: %.c05: type = fn_type_with_self_type %Iterate.WithSelf.NewCursor.type.49d, %Iterate.facet.758 [concrete]
|
||||
@@ -1882,6 +1881,7 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd,
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.Next.specific_fn.288: <specific function> = specific_function %T.as_type.as.Iterate.impl.Next.8ce, @T.as_type.as.Iterate.impl.Next(%facet_value.4bb) [concrete]
|
||||
// CHECK:STDOUT: %Destroy.WithSelf.SelfDestruct.type.baf: type = fn_type @Destroy.WithSelf.SelfDestruct.1, @Destroy.WithSelf(%Destroy.facet.645) [concrete]
|
||||
// CHECK:STDOUT: %.085: type = fn_type_with_self_type %Destroy.WithSelf.SelfDestruct.type.baf, %Destroy.facet.645 [concrete]
|
||||
// CHECK:STDOUT: %Iterate.facet.930: %Iterate.type = facet_value %DiffConstRange, (%Iterate.impl_witness.9b4) [concrete]
|
||||
// CHECK:STDOUT: %Iterate.WithSelf.NewCursor.type.4f6: type = fn_type @Iterate.WithSelf.NewCursor, @Iterate.WithSelf(%Iterate.facet.930) [concrete]
|
||||
// CHECK:STDOUT: %Iterate.WithSelf.Next.type.95d: type = fn_type @Iterate.WithSelf.Next, @Iterate.WithSelf(%Iterate.facet.930) [concrete]
|
||||
// CHECK:STDOUT: %.b0d: type = fn_type_with_self_type %Iterate.WithSelf.NewCursor.type.4f6, %Iterate.facet.930 [concrete]
|
||||
@@ -2646,10 +2646,10 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd,
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.NewCursor.60e: %T.as_type.as.Iterate.impl.NewCursor.type.549 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.Next.type.c07: type = fn_type @T.as_type.as.Iterate.impl.Next, @T.as_type.as.Iterate.impl(%facet_value.8e3) [concrete]
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.Next.23c: %T.as_type.as.Iterate.impl.Next.type.c07 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %Iterate.facet.a3e: %Iterate.type = facet_value %Range, (%Iterate.impl_witness.e03) [concrete]
|
||||
// CHECK:STDOUT: %facet_value.637: %Iterate_where.type.2ee = facet_value %Range, (%Iterate.impl_witness.e03) [concrete]
|
||||
// CHECK:STDOUT: %r.patt.b9f: %pattern_type.23f = ref_binding_pattern r [concrete]
|
||||
// CHECK:STDOUT: %r.param_patt.466: %pattern_type.23f = var_param_pattern %r.patt.b9f [concrete]
|
||||
// CHECK:STDOUT: %Iterate.facet.a3e: %Iterate.type = facet_value %Range, (%Iterate.impl_witness.e03) [concrete]
|
||||
// CHECK:STDOUT: %Iterate.WithSelf.NewCursor.type.b10: type = fn_type @Iterate.WithSelf.NewCursor, @Iterate.WithSelf(%Iterate.facet.a3e) [concrete]
|
||||
// CHECK:STDOUT: %Iterate.WithSelf.Next.type.42b: type = fn_type @Iterate.WithSelf.Next, @Iterate.WithSelf(%Iterate.facet.a3e) [concrete]
|
||||
// CHECK:STDOUT: %.f2a: type = fn_type_with_self_type %Iterate.WithSelf.NewCursor.type.b10, %Iterate.facet.a3e [concrete]
|
||||
@@ -3298,10 +3298,10 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd,
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.NewCursor.1ed: %T.as_type.as.Iterate.impl.NewCursor.type.35f = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.Next.type.6c4: type = fn_type @T.as_type.as.Iterate.impl.Next, @T.as_type.as.Iterate.impl(%facet_value.120) [concrete]
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.Next.9ad: %T.as_type.as.Iterate.impl.Next.type.6c4 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %Iterate.facet.1a5: %Iterate.type = facet_value %ConstRange, (%Iterate.impl_witness.a53) [concrete]
|
||||
// CHECK:STDOUT: %facet_value.36b: %Iterate_where.type.11d = facet_value %ConstRange, (%Iterate.impl_witness.a53) [concrete]
|
||||
// CHECK:STDOUT: %r.param_patt.a73: %pattern_type.025 = value_param_pattern [concrete]
|
||||
// CHECK:STDOUT: %r.patt.0b5: %pattern_type.025 = wrapper_binding_pattern r, %r.param_patt.a73 [concrete]
|
||||
// CHECK:STDOUT: %Iterate.facet.1a5: %Iterate.type = facet_value %ConstRange, (%Iterate.impl_witness.a53) [concrete]
|
||||
// CHECK:STDOUT: %Iterate.WithSelf.NewCursor.type.793: type = fn_type @Iterate.WithSelf.NewCursor, @Iterate.WithSelf(%Iterate.facet.1a5) [concrete]
|
||||
// CHECK:STDOUT: %Iterate.WithSelf.Next.type.c0d: type = fn_type @Iterate.WithSelf.Next, @Iterate.WithSelf(%Iterate.facet.1a5) [concrete]
|
||||
// CHECK:STDOUT: %.588: type = fn_type_with_self_type %Iterate.WithSelf.NewCursor.type.793, %Iterate.facet.1a5 [concrete]
|
||||
@@ -3947,10 +3947,10 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd,
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.NewCursor.f32: %T.as_type.as.Iterate.impl.NewCursor.type.c03 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.Next.type.06b: type = fn_type @T.as_type.as.Iterate.impl.Next, @T.as_type.as.Iterate.impl(%facet_value.c62) [concrete]
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.Next.8a0: %T.as_type.as.Iterate.impl.Next.type.06b = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %Iterate.facet.b38: %Iterate.type = facet_value %MutableRange, (%Iterate.impl_witness.8eb) [concrete]
|
||||
// CHECK:STDOUT: %facet_value.da8: %Iterate_where.type.11d = facet_value %MutableRange, (%Iterate.impl_witness.8eb) [concrete]
|
||||
// CHECK:STDOUT: %r.param_patt.aeb: %pattern_type.992 = value_param_pattern [concrete]
|
||||
// CHECK:STDOUT: %r.patt.892: %pattern_type.992 = wrapper_binding_pattern r, %r.param_patt.aeb [concrete]
|
||||
// CHECK:STDOUT: %Iterate.facet.b38: %Iterate.type = facet_value %MutableRange, (%Iterate.impl_witness.8eb) [concrete]
|
||||
// CHECK:STDOUT: %Iterate.WithSelf.NewCursor.type.601: type = fn_type @Iterate.WithSelf.NewCursor, @Iterate.WithSelf(%Iterate.facet.b38) [concrete]
|
||||
// CHECK:STDOUT: %Iterate.WithSelf.Next.type.63c: type = fn_type @Iterate.WithSelf.Next, @Iterate.WithSelf(%Iterate.facet.b38) [concrete]
|
||||
// CHECK:STDOUT: %.177: type = fn_type_with_self_type %Iterate.WithSelf.NewCursor.type.601, %Iterate.facet.b38 [concrete]
|
||||
@@ -4599,10 +4599,10 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd,
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.NewCursor.437: %T.as_type.as.Iterate.impl.NewCursor.type.755 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.Next.type.b75: type = fn_type @T.as_type.as.Iterate.impl.Next, @T.as_type.as.Iterate.impl(%facet_value.d15) [concrete]
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.Next.82c: %T.as_type.as.Iterate.impl.Next.type.b75 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %Iterate.facet.8d3: %Iterate.type = facet_value %ConstRange, (%Iterate.impl_witness.d1d) [concrete]
|
||||
// CHECK:STDOUT: %facet_value.1d8: %Iterate_where.type.87e = facet_value %ConstRange, (%Iterate.impl_witness.d1d) [concrete]
|
||||
// CHECK:STDOUT: %r.param_patt.ac5: %pattern_type.c1d = value_param_pattern [concrete]
|
||||
// CHECK:STDOUT: %r.patt.97f: %pattern_type.c1d = wrapper_binding_pattern r, %r.param_patt.ac5 [concrete]
|
||||
// CHECK:STDOUT: %Iterate.facet.8d3: %Iterate.type = facet_value %ConstRange, (%Iterate.impl_witness.d1d) [concrete]
|
||||
// CHECK:STDOUT: %Iterate.WithSelf.NewCursor.type.7f7: type = fn_type @Iterate.WithSelf.NewCursor, @Iterate.WithSelf(%Iterate.facet.8d3) [concrete]
|
||||
// CHECK:STDOUT: %Iterate.WithSelf.Next.type.035: type = fn_type @Iterate.WithSelf.Next, @Iterate.WithSelf(%Iterate.facet.8d3) [concrete]
|
||||
// CHECK:STDOUT: %.8c0: type = fn_type_with_self_type %Iterate.WithSelf.NewCursor.type.7f7, %Iterate.facet.8d3 [concrete]
|
||||
@@ -5768,10 +5768,10 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd,
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.NewCursor.160: %T.as_type.as.Iterate.impl.NewCursor.type.212 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.Next.type.6dd: type = fn_type @T.as_type.as.Iterate.impl.Next, @T.as_type.as.Iterate.impl(%facet_value.24f) [concrete]
|
||||
// CHECK:STDOUT: %T.as_type.as.Iterate.impl.Next.ddf: %T.as_type.as.Iterate.impl.Next.type.6dd = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %Iterate.facet.b30: %Iterate.type = facet_value %MutableAndConstRange, (%Iterate.impl_witness.198) [concrete]
|
||||
// CHECK:STDOUT: %facet_value.fc8: %Iterate_where.type.8b0 = facet_value %MutableAndConstRange, (%Iterate.impl_witness.198) [concrete]
|
||||
// CHECK:STDOUT: %r.param_patt.3a6: %pattern_type.fdb = value_param_pattern [concrete]
|
||||
// CHECK:STDOUT: %r.patt.403: %pattern_type.fdb = wrapper_binding_pattern r, %r.param_patt.3a6 [concrete]
|
||||
// CHECK:STDOUT: %Iterate.facet.b30: %Iterate.type = facet_value %MutableAndConstRange, (%Iterate.impl_witness.198) [concrete]
|
||||
// CHECK:STDOUT: %Iterate.WithSelf.NewCursor.type.b5a: type = fn_type @Iterate.WithSelf.NewCursor, @Iterate.WithSelf(%Iterate.facet.b30) [concrete]
|
||||
// CHECK:STDOUT: %Iterate.WithSelf.Next.type.3b0: type = fn_type @Iterate.WithSelf.Next, @Iterate.WithSelf(%Iterate.facet.b30) [concrete]
|
||||
// CHECK:STDOUT: %.bc1: type = fn_type_with_self_type %Iterate.WithSelf.NewCursor.type.b5a, %Iterate.facet.b30 [concrete]
|
||||
|
||||
+10
-8
@@ -572,7 +572,7 @@ fn F() {
|
||||
() as N({});
|
||||
}
|
||||
|
||||
// --- todo_fail_require_with_mismatching_rewrite_constraint.carbon
|
||||
// --- fail_require_with_mismatching_rewrite_constraint.carbon
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
interface Z(T: type) {
|
||||
@@ -587,13 +587,14 @@ constraint N {
|
||||
impl {} as Z(()) where .X = {} {}
|
||||
|
||||
fn F() {
|
||||
// TODO: Should fail, but we're currently checking the requirements of `N`
|
||||
// rather than of the identified facet type of `N` (which would include the
|
||||
// require decl's requirements).
|
||||
// CHECK:STDERR: fail_require_with_mismatching_rewrite_constraint.carbon:[[@LINE+4]]:3: error: cannot convert type `()` into type implementing `N` [ConversionFailureTypeToFacet]
|
||||
// CHECK:STDERR: () as N;
|
||||
// CHECK:STDERR: ^~~~~~~
|
||||
// CHECK:STDERR:
|
||||
() as N;
|
||||
}
|
||||
|
||||
// --- todo_fail_require_with_mismatching_rewrite_constraint_period_self.carbon
|
||||
// --- fail_require_with_mismatching_rewrite_constraint_period_self.carbon
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
interface Z(T: type) {
|
||||
@@ -608,9 +609,10 @@ constraint N(T: type) {
|
||||
impl {} as Z(()) where .X = () {}
|
||||
|
||||
fn F() {
|
||||
// TODO: Should fail, but we're currently checking the requirements of `N`
|
||||
// rather than of the identified facet type of `N` (which would include the
|
||||
// require decl's requirements).
|
||||
// CHECK:STDERR: fail_require_with_mismatching_rewrite_constraint_period_self.carbon:[[@LINE+4]]:3: error: cannot convert type `()` into type implementing `N({})` [ConversionFailureTypeToFacet]
|
||||
// CHECK:STDERR: () as N({});
|
||||
// CHECK:STDERR: ^~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
() as N({});
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -141,7 +141,7 @@ import library "state_constraints";
|
||||
class C {}
|
||||
impl C as J {}
|
||||
|
||||
fn EmptyStruct(generic Y: J where .Self == {});
|
||||
fn EmptyStruct(unused generic Y: J where .Self == {}) {}
|
||||
|
||||
// TODO: Should report that `C` does not meeet the `==` constraint. Right
|
||||
// now there is no support for `==` constraints so it rejects it as an
|
||||
@@ -150,9 +150,9 @@ fn NotEmptyStruct() {
|
||||
// CHECK:STDERR: fail_todo_enforce_equality_constraint.carbon:[[@LINE+7]]:3: error: cannot convert type `C` into type implementing `J where...` [ConversionFailureTypeToFacet]
|
||||
// CHECK:STDERR: EmptyStruct(C);
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_todo_enforce_equality_constraint.carbon:[[@LINE-9]]:24: note: initializing generic parameter `Y` declared here [InitializingGenericParam]
|
||||
// CHECK:STDERR: fn EmptyStruct(generic Y: J where .Self == {});
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_todo_enforce_equality_constraint.carbon:[[@LINE-9]]:31: note: initializing generic parameter `Y` declared here [InitializingGenericParam]
|
||||
// CHECK:STDERR: fn EmptyStruct(unused generic Y: J where .Self == {}) {}
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
EmptyStruct(C);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user