diff --git a/toolchain/check/eval.cpp b/toolchain/check/eval.cpp index f10d199fc23a..68b1965d4ae9 100644 --- a/toolchain/check/eval.cpp +++ b/toolchain/check/eval.cpp @@ -685,8 +685,15 @@ static auto GetConstantValue(EvalContext& eval_context, if (args_id == specific.args_id) { return specific_id; } - return eval_context.context().specifics().GetOrAdd( - specific.generic_id, args_id, specific.identified); + // When modifying a non-`identified` specific during identify, mark the new + // specific as `identified` too. If modifying an `identified` specific outside + // of identify, it may contain `IdentifiedWitness` insts so the new specific + // must keep the `identified` marker. + bool identified = + eval_context.context().eval_impl_lookup_to_identified_witness() || + specific.identified; + return eval_context.context().specifics().GetOrAdd(specific.generic_id, + args_id, identified); } static auto GetConstantValue(EvalContext& eval_context, diff --git a/toolchain/check/facet_type.cpp b/toolchain/check/facet_type.cpp index 399d012d1ae6..bb573f3c919b 100644 --- a/toolchain/check/facet_type.cpp +++ b/toolchain/check/facet_type.cpp @@ -584,6 +584,16 @@ class EvaluateSubstCallbacks : public SubstInstCallbacks { return RebuildNewInst(loc_id_, new_inst); } + auto RebuildSpecific(SemIR::SpecificId orig_specific_id, + SemIR::InstBlockId args_id) + -> SemIR::SpecificId override { + auto generic_id = context().specifics().Get(orig_specific_id).generic_id; + // Drop the `identified` flag from any specifics we create here, as we have + // substituted the IdentifiedWitness instructions away. + return context().specifics().GetOrAdd(generic_id, args_id, + /*identified=*/false); + } + private: auto SubstIdentifiedWitness(SemIR::IdentifiedWitness witness) -> SemIR::InstId { diff --git a/toolchain/check/generic.cpp b/toolchain/check/generic.cpp index 03cc5be3a49f..12706ac698f5 100644 --- a/toolchain/check/generic.cpp +++ b/toolchain/check/generic.cpp @@ -716,21 +716,19 @@ auto ResolveSpecificDecl(Context& context, SemIR::LocId loc_id, } auto MakeSpecific(Context& context, SemIR::LocId loc_id, - SemIR::GenericId generic_id, SemIR::InstBlockId args_id, - bool make_identified_specific) -> SemIR::SpecificId { - auto specific_id = context.specifics().GetOrAdd(generic_id, args_id, - make_identified_specific); + SemIR::GenericId generic_id, SemIR::InstBlockId args_id) + -> SemIR::SpecificId { + auto specific_id = context.specifics().GetOrAdd( + generic_id, args_id, context.eval_impl_lookup_to_identified_witness()); ResolveSpecificDecl(context, loc_id, specific_id); return specific_id; } auto MakeSpecific(Context& context, SemIR::LocId loc_id, SemIR::GenericId generic_id, - llvm::ArrayRef args, - bool make_identified_specific) -> SemIR::SpecificId { + llvm::ArrayRef args) -> SemIR::SpecificId { auto args_id = context.inst_blocks().AddCanonical(args); - return MakeSpecific(context, loc_id, generic_id, args_id, - make_identified_specific); + return MakeSpecific(context, loc_id, generic_id, args_id); } static auto MakeSelfSpecificId(Context& context, SemIR::GenericId generic_id) @@ -878,8 +876,7 @@ auto MakeSpecificWithInnerSelf(Context& context, SemIR::LocId loc_id, SemIR::GenericId generic_without_self_id, SemIR::GenericId generic_with_self_id, SemIR::SpecificId specific_without_self_id, - SemIR::ConstantId self_facet, - bool make_identified_specific) + SemIR::ConstantId self_facet) -> SemIR::SpecificId { ValidateGenericWithoutAndWithSelfMatch(context, generic_without_self_id, generic_with_self_id, @@ -904,16 +901,15 @@ auto MakeSpecificWithInnerSelf(Context& context, SemIR::LocId loc_id, args.push_back(self_facet_inst_id); } - auto specific_id = MakeSpecific(context, loc_id, generic_with_self_id, args, - make_identified_specific); + auto specific_id = MakeSpecific(context, loc_id, generic_with_self_id, args); ResolveSpecificDefinition(context, loc_id, specific_id); return specific_id; } auto CopySpecificToGeneric(Context& context, SemIR::LocId loc_id, SemIR::SpecificId specific_id, - SemIR::GenericId target_generic_id, - bool make_identified_specific) -> SemIR::SpecificId { + SemIR::GenericId target_generic_id) + -> SemIR::SpecificId { if (!specific_id.has_value()) { const auto& target_generic = context.generics().Get(target_generic_id); auto target_bindings = @@ -936,8 +932,7 @@ auto CopySpecificToGeneric(Context& context, SemIR::LocId loc_id, } auto args_id = context.specifics().GetArgsOrEmpty(specific_id); - return MakeSpecific(context, loc_id, target_generic_id, args_id, - make_identified_specific); + return MakeSpecific(context, loc_id, target_generic_id, args_id); } auto DiagnoseImplsOnNonFacetType(Context& context, SemIR::LocId loc_id) diff --git a/toolchain/check/generic.h b/toolchain/check/generic.h index fcfad5c9e040..0eebcef155ca 100644 --- a/toolchain/check/generic.h +++ b/toolchain/check/generic.h @@ -102,15 +102,14 @@ auto RebuildGenericEvalBlock(Context& context, SemIR::GenericId generic_id, // substitution into the declaration, but not the definition, of the generic. auto MakeSpecific(Context& context, SemIR::LocId loc_id, SemIR::GenericId generic_id, - llvm::ArrayRef args, - bool make_identified_specific = false) -> SemIR::SpecificId; + llvm::ArrayRef args) -> SemIR::SpecificId; // Builds a new specific or finds an existing one in the case where the argument // list has already been converted into an instruction block. `args_id` should // be a canonical instruction block referring to constants. auto MakeSpecific(Context& context, SemIR::LocId loc_id, - SemIR::GenericId generic_id, SemIR::InstBlockId args_id, - bool make_identified_specific = false) -> SemIR::SpecificId; + SemIR::GenericId generic_id, SemIR::InstBlockId args_id) + -> SemIR::SpecificId; // Builds the specific that describes how the generic should refer to itself. // For example, for a generic `G(T: type)`, this is the specific `G(T)`. If @@ -163,8 +162,7 @@ auto MakeSpecificWithInnerSelf(Context& context, SemIR::LocId loc_id, SemIR::GenericId generic_without_self_id, SemIR::GenericId generic_with_self_id, SemIR::SpecificId specific_without_self_id, - SemIR::ConstantId self_facet, - bool make_identified_specific = false) + SemIR::ConstantId self_facet) -> SemIR::SpecificId; // Copy the arguments of a specific into the context of another generic. The @@ -176,8 +174,7 @@ auto MakeSpecificWithInnerSelf(Context& context, SemIR::LocId loc_id, // instantiation. auto CopySpecificToGeneric(Context& context, SemIR::LocId loc_id, SemIR::SpecificId specific_id, - SemIR::GenericId target_generic_id, - bool make_identified_specific = false) + SemIR::GenericId target_generic_id) -> SemIR::SpecificId; auto DiagnoseImplsOnNonFacetType(Context& context, SemIR::LocId loc_id) -> void; diff --git a/toolchain/check/subst.cpp b/toolchain/check/subst.cpp index f992f9be58bf..52534237e184 100644 --- a/toolchain/check/subst.cpp +++ b/toolchain/check/subst.cpp @@ -21,6 +21,27 @@ auto SubstInstCallbacks::RebuildType(SemIR::TypeInstId type_inst_id) const return context().types().GetTypeIdForTypeInstId(type_inst_id); } +auto SubstInstCallbacks::RebuildSpecific(SemIR::SpecificId orig_specific_id, + SemIR::InstBlockId args_id) + -> SemIR::SpecificId { + // TODO: We do not resolve specifics formed from Subst, so we can't call + // MakeSpecific here. + const auto& orig_specific = context().specifics().Get(orig_specific_id); + if (args_id == orig_specific.args_id) { + // If the args didn't change, avoid constructing an `identified` specific + // even during identify. + return orig_specific_id; + } + // When modifying a non-`identified` specific during identify, mark the new + // specific as `identified` too. If modifying an `identified` specific outside + // of identify, it may contain `IdentifiedWitness` insts so the new specific + // must keep the `identified` marker. + bool identified = context().eval_impl_lookup_to_identified_witness() || + orig_specific.identified; + return context().specifics().GetOrAdd(orig_specific.generic_id, args_id, + identified); +} + auto SubstInstCallbacks::RebuildNewInst(SemIR::LocId loc_id, SemIR::Inst new_inst) const -> SemIR::InstId { @@ -187,7 +208,8 @@ static auto ExpandOperands(Context& context, Worklist& worklist, // Pops the specified operand from the worklist and returns it. static auto PopOperand(Context& context, Worklist& worklist, - SemIR::IdAndKind arg) -> int32_t { + SemIR::IdAndKind arg, SubstInstCallbacks& callbacks) + -> int32_t { auto pop_block_id = [&](SemIR::InstBlockId old_inst_block_id) { auto size = context.inst_blocks().Get(old_inst_block_id).size(); SemIR::CopyOnWriteInstBlock new_inst_block(&context.sem_ir(), @@ -204,8 +226,7 @@ static auto PopOperand(Context& context, Worklist& worklist, } auto& specific = context.specifics().Get(specific_id); auto args_id = pop_block_id(specific.args_id); - return context.specifics().GetOrAdd(specific.generic_id, args_id, - specific.identified); + return callbacks.RebuildSpecific(specific_id, args_id); }; CARBON_KIND_SWITCH(arg) { @@ -353,8 +374,8 @@ static auto Rebuild(Context& context, Worklist& worklist, SemIR::InstId inst_id, auto inst = context.insts().Get(inst_id); // Note that we pop in reverse order because we pushed them in forwards order. - int32_t arg1 = PopOperand(context, worklist, inst.arg1_and_kind()); - int32_t arg0 = PopOperand(context, worklist, inst.arg0_and_kind()); + int32_t arg1 = PopOperand(context, worklist, inst.arg1_and_kind(), callbacks); + int32_t arg0 = PopOperand(context, worklist, inst.arg0_and_kind(), callbacks); auto type_id = inst.type_id().has_value() ? callbacks.RebuildType( context.types().GetAsTypeInstId(worklist.Pop())) diff --git a/toolchain/check/subst.h b/toolchain/check/subst.h index 8705235fba5d..36590eabcb55 100644 --- a/toolchain/check/subst.h +++ b/toolchain/check/subst.h @@ -79,6 +79,12 @@ class SubstInstCallbacks { return orig_inst_id; } + // Rebuilds a specific given the original specific's ID and the new + // arguments. By default this just calls GetOrAdd to make the specific, but + // does not resolve the specific's decl block. + virtual auto RebuildSpecific(SemIR::SpecificId orig_specific_id, + SemIR::InstBlockId args_id) -> SemIR::SpecificId; + // Builds a new constant by evaluating `new_inst`, and returns its `InstId`. // // This can be used to implement `Rebuild` in straightforward cases. diff --git a/toolchain/check/testdata/facet/period_self.carbon b/toolchain/check/testdata/facet/period_self.carbon index b59e40f8b0f5..f322704fe03a 100644 --- a/toolchain/check/testdata/facet/period_self.carbon +++ b/toolchain/check/testdata/facet/period_self.carbon @@ -1088,6 +1088,11 @@ impl forall [T: type] T as Y(Z where .Z1 = ()) where .Y1 = .YF() {} // CHECK:STDOUT: %assoc0 => constants.%assoc0.1a5 // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @I(constants.%T.as_type):identified { +// CHECK:STDOUT: %T.patt.loc4_14.2 => constants.%T.patt.3a0 +// CHECK:STDOUT: %T.loc4_14.1 => constants.%T.as_type +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: specific @I(constants.%T.as_type) { // CHECK:STDOUT: %T.patt.loc4_14.2 => constants.%T.patt.3a0 // CHECK:STDOUT: %T.loc4_14.1 => constants.%T.as_type diff --git a/toolchain/check/testdata/facet/require_import.carbon b/toolchain/check/testdata/facet/require_import.carbon index b72dfdcd256c..a718d6edccea 100644 --- a/toolchain/check/testdata/facet/require_import.carbon +++ b/toolchain/check/testdata/facet/require_import.carbon @@ -89,6 +89,8 @@ fn F(generic B: Y) { // CHECK:STDOUT: %Z.assoc_type.4e0: type = assoc_entity_type @Z, @Z(%A.as_type) [symbolic] // CHECK:STDOUT: %assoc0.de7: %Z.assoc_type.4e0 = assoc_entity element0, imports.%Main.import_ref.7eb [symbolic] // CHECK:STDOUT: %assoc0.a64: %Z.assoc_type.795 = assoc_entity element0, imports.%Main.import_ref.f35 [symbolic] +// CHECK:STDOUT: %Z.type.67e: type = facet_type <@Z, @Z(%A.as_type):identified> [symbolic] +// CHECK:STDOUT: %require_complete.d81: = require_complete_type %Z.type.67e [symbolic] // CHECK:STDOUT: %Z.lookup_impl_witness: = lookup_impl_witness %A, @Z, @Z(%A.as_type) [symbolic] // CHECK:STDOUT: %Z.facet: %Z.type.56f318.2 = facet_value %A.as_type, (%Z.lookup_impl_witness) [symbolic] // CHECK:STDOUT: %Z.WithSelf.F.type.20b: type = fn_type @Z.WithSelf.F, @Z.WithSelf(%A.as_type, %Z.facet) [symbolic] @@ -318,18 +320,23 @@ fn F(generic B: Y) { // CHECK:STDOUT: %assoc0 => constants.%assoc0.de7 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @X.WithSelf(constants.%A) [identified] { +// CHECK:STDOUT: specific @X.WithSelf(constants.%A):identified { // CHECK:STDOUT: !definition: // CHECK:STDOUT: %Self => constants.%A // CHECK:STDOUT: %Self.as_type => constants.%A.as_type -// CHECK:STDOUT: %Z.type => constants.%Z.type.56f318.2 -// CHECK:STDOUT: %require_complete => constants.%require_complete.327231.2 +// CHECK:STDOUT: %Z.type => constants.%Z.type.67e +// CHECK:STDOUT: %require_complete => constants.%require_complete.d81 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @X.WithSelf.Self.as_type.impls.Z.type.require(constants.%A) [identified] { +// CHECK:STDOUT: specific @Z(constants.%A.as_type):identified { +// CHECK:STDOUT: %T.patt => constants.%T.patt +// CHECK:STDOUT: %T => constants.%A.as_type +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @X.WithSelf.Self.as_type.impls.Z.type.require(constants.%A):identified { // CHECK:STDOUT: %Self => constants.%A // CHECK:STDOUT: %Self.as_type => constants.%A.as_type -// CHECK:STDOUT: %Z.type => constants.%Z.type.56f318.2 +// CHECK:STDOUT: %Z.type => constants.%Z.type.67e // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @Z.WithSelf(constants.%A.as_type, constants.%Z.facet) { diff --git a/toolchain/check/testdata/impl/impl_as_named_constraint.carbon b/toolchain/check/testdata/impl/impl_as_named_constraint.carbon index 87c36217bfe1..614e6e92600a 100644 --- a/toolchain/check/testdata/impl/impl_as_named_constraint.carbon +++ b/toolchain/check/testdata/impl/impl_as_named_constraint.carbon @@ -151,6 +151,20 @@ constraint B(X: Undefined) { impl () as B(1) {} +// --- fail_todo_impl_as_constraint_duplicates_interface.carbon +library "[[@TEST_NAME]]"; + +interface I(T: type) {} +constraint J { + extend require impls I(Self); +} + +// This impls `I(())` twice, which should be deduplicated to a single specific +// interface. +// CHECK:STDERR: fail_todo_impl_as_constraint_duplicates_interface.carbon:[[@LINE+2]]:1-22: error: impl as 2 interfaces, expected 1 [ImplOfNotOneInterface] +// CHECK:STDERR: +impl () as I(()) & J {} + // --- impl_as_constraint_where_rewrite.carbon library "[[@TEST_NAME]]"; @@ -345,6 +359,31 @@ fn G() { F(()); } +// --- access_through_nested_specific_in_named_constraint.carbon +library "[[@TEST_NAME]]"; + +interface Z { let Z1: type; } +impl forall [T: type] T as Z where .Z1 = {} {} + +class C(T: type) { + alias U = T.(Z.Z1); +} + +interface K {} + +constraint J { + extend require impls Z; + // When identifying `() as J` for the impl below, this forms a specific `C(())` + // which contains an access of `().(Z.Z1)`. The `() as Z` lookup _should_ find + // the impl below, not the blanket impl above. If we find the above impl, then + // the access of `U` here resolves to `{}` incorrectly. + require C(Self).U impls K; +} + +impl () as K {} + +impl () as J where .Z1 = () {} + // --- witness_access_in_named_constraint.carbon library "[[@TEST_NAME]]"; diff --git a/toolchain/check/testdata/impl/import_generic.carbon b/toolchain/check/testdata/impl/import_generic.carbon index 96e5316467f5..56100849431c 100644 --- a/toolchain/check/testdata/impl/import_generic.carbon +++ b/toolchain/check/testdata/impl/import_generic.carbon @@ -684,12 +684,16 @@ impl forall [T: type] D as N(T*) {} // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self.e1f642.1 [symbolic] // CHECK:STDOUT: %empty_struct.a40: %empty_struct_type = struct_value () [concrete] // CHECK:STDOUT: %J.type.d682d6.2: type = facet_type <@J, @J(%empty_struct_type)> [concrete] -// CHECK:STDOUT: %I.type.aaf: type = facet_type <@I, @I(%empty_struct_type)> [concrete] -// CHECK:STDOUT: %Self.968: %I.type.aaf = symbolic_binding Self, 1 [symbolic] -// CHECK:STDOUT: %complete_type.a15: = complete_type_witness %I.type.aaf [concrete] +// CHECK:STDOUT: %I.type.aab: type = facet_type <@I, @I(%empty_struct_type):identified> [concrete] +// CHECK:STDOUT: %Self.551: %I.type.aab = symbolic_binding Self, 1 [symbolic] +// CHECK:STDOUT: %complete_type.8b4: = complete_type_witness %I.type.aab [concrete] +// CHECK:STDOUT: %J.type.d682d6.3: type = facet_type <@J, @J(%empty_struct_type):identified> [concrete] // CHECK:STDOUT: %.ea2: = impl_self_witness %C, @I, @I(%empty_struct_type) [concrete] // CHECK:STDOUT: %I.impl_witness: = impl_witness @C.as.I.impl.%I.impl_witness_table [concrete] // CHECK:STDOUT: %Self.e1f642.2: %J.type.d682d6.2 = symbolic_binding Self, 1 [symbolic] +// CHECK:STDOUT: %I.type.aaf: type = facet_type <@I, @I(%empty_struct_type)> [concrete] +// CHECK:STDOUT: %Self.968: %I.type.aaf = symbolic_binding Self, 1 [symbolic] +// CHECK:STDOUT: %complete_type.a15: = complete_type_witness %I.type.aaf [concrete] // CHECK:STDOUT: %I.facet: %I.type.aaf = facet_value %C, (%I.impl_witness) [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -825,11 +829,37 @@ impl forall [T: type] D as N(T*) {} // CHECK:STDOUT: %Self => constants.%Self.e1f642.2 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @J.WithSelf(constants.%empty_struct_type, constants.%C) [identified] { +// CHECK:STDOUT: specific @J.WithSelf(constants.%empty_struct_type, constants.%C):identified { // CHECK:STDOUT: !definition: // CHECK:STDOUT: %T => constants.%empty_struct_type -// CHECK:STDOUT: %I.type => constants.%I.type.aaf -// CHECK:STDOUT: %require_complete => constants.%complete_type.a15 +// CHECK:STDOUT: %I.type => constants.%I.type.aab +// CHECK:STDOUT: %require_complete => constants.%complete_type.8b4 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @I(constants.%empty_struct_type):identified { +// CHECK:STDOUT: %T.patt => constants.%T.patt +// CHECK:STDOUT: %T => constants.%empty_struct_type +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %I.type => constants.%I.type.aab +// CHECK:STDOUT: %Self => constants.%Self.551 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @I.WithSelf(constants.%empty_struct_type, constants.%Self.a4f):identified { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @J.WithSelf.Self.as_type.impls.I.type.require(constants.%empty_struct_type, constants.%C):identified { +// CHECK:STDOUT: %T => constants.%empty_struct_type +// CHECK:STDOUT: %J.type => constants.%J.type.d682d6.3 +// CHECK:STDOUT: %Self => constants.%C +// CHECK:STDOUT: %Self.as_type => constants.%C +// CHECK:STDOUT: %I.type => constants.%I.type.aab +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @J(constants.%empty_struct_type):identified { +// CHECK:STDOUT: %T.patt => constants.%T.patt +// CHECK:STDOUT: %T => constants.%empty_struct_type // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @I(constants.%empty_struct_type) { @@ -841,18 +871,6 @@ impl forall [T: type] D as N(T*) {} // CHECK:STDOUT: %Self => constants.%Self.968 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @I.WithSelf(constants.%empty_struct_type, constants.%Self.a4f) { -// CHECK:STDOUT: !definition: -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: specific @J.WithSelf.Self.as_type.impls.I.type.require(constants.%empty_struct_type, constants.%C) [identified] { -// CHECK:STDOUT: %T => constants.%empty_struct_type -// CHECK:STDOUT: %J.type => constants.%J.type.d682d6.2 -// CHECK:STDOUT: %Self => constants.%C -// CHECK:STDOUT: %Self.as_type => constants.%C -// CHECK:STDOUT: %I.type => constants.%I.type.aaf -// CHECK:STDOUT: } -// CHECK:STDOUT: // CHECK:STDOUT: specific @J.WithSelf(constants.%empty_struct_type, constants.%Self.e1f642.1) { // CHECK:STDOUT: !definition: // CHECK:STDOUT: %T => constants.%empty_struct_type @@ -860,6 +878,10 @@ impl forall [T: type] D as N(T*) {} // CHECK:STDOUT: %require_complete => constants.%complete_type.a15 // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @I.WithSelf(constants.%empty_struct_type, constants.%Self.a4f) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: specific @I.WithSelf(constants.%empty_struct_type, constants.%I.facet) { // CHECK:STDOUT: !definition: // CHECK:STDOUT: } @@ -1178,7 +1200,13 @@ impl forall [T: type] D as N(T*) {} // CHECK:STDOUT: %N.type.d682d6.1: type = facet_type <@N, @N(%T)> [symbolic] // CHECK:STDOUT: %Self.e1f: %N.type.d682d6.1 = symbolic_binding Self, 1 [symbolic] // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self.e1f [symbolic] -// CHECK:STDOUT: %N.type.d682d6.2: type = facet_type <@N, @N(%ptr)> [symbolic] +// CHECK:STDOUT: %I.type.d5d: type = facet_type <@I, @I(%T):identified> [symbolic] +// CHECK:STDOUT: %require_complete.bb5: = require_complete_type %I.type.d5d [symbolic] +// CHECK:STDOUT: %N.type.d682d6.2: type = facet_type <@N, @N(%T):identified> [symbolic] +// CHECK:STDOUT: %N.type.d682d6.3: type = facet_type <@N, @N(%ptr)> [symbolic] +// CHECK:STDOUT: %I.type.97e: type = facet_type <@I, @I(%ptr):identified> [symbolic] +// CHECK:STDOUT: %require_complete.bfd: = require_complete_type %I.type.97e [symbolic] +// CHECK:STDOUT: %N.type.d682d6.4: type = facet_type <@N, @N(%ptr):identified> [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -1297,7 +1325,7 @@ impl forall [T: type] D as N(T*) {} // CHECK:STDOUT: %N.ref: %N.type.b76 = name_ref N, imports.%Main.N [concrete = constants.%empty_struct] // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc25_15.1 [symbolic = %T.loc25_15.2 (constants.%T)] // CHECK:STDOUT: %ptr.loc25_31.1: type = ptr_type %T.ref [symbolic = %ptr.loc25_31.2 (constants.%ptr)] -// CHECK:STDOUT: %N.type.loc25_32.1: type = facet_type <@N, @N(constants.%ptr)> [symbolic = %N.type.loc25_32.2 (constants.%N.type.d682d6.2)] +// CHECK:STDOUT: %N.type.loc25_32.1: type = facet_type <@N, @N(constants.%ptr)> [symbolic = %N.type.loc25_32.2 (constants.%N.type.d682d6.3)] // CHECK:STDOUT: %.loc25_17.1: type = splice_block %.loc25_17.2 [concrete = type] { // CHECK:STDOUT: %.Self.frozen: type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen] // CHECK:STDOUT: %.loc25_17.2: type = type_literal type [concrete = type] @@ -1450,7 +1478,7 @@ impl forall [T: type] D as N(T*) {} // CHECK:STDOUT: %T.patt.loc25_15.2: %pattern_type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc25_15.2 (constants.%T.patt)] // CHECK:STDOUT: %T.loc25_15.2: type = symbolic_binding T, 0 [symbolic = %T.loc25_15.2 (constants.%T)] // CHECK:STDOUT: %ptr.loc25_31.2: type = ptr_type %T.loc25_15.2 [symbolic = %ptr.loc25_31.2 (constants.%ptr)] -// CHECK:STDOUT: %N.type.loc25_32.2: type = facet_type <@N, @N(%ptr.loc25_31.2)> [symbolic = %N.type.loc25_32.2 (constants.%N.type.d682d6.2)] +// CHECK:STDOUT: %N.type.loc25_32.2: type = facet_type <@N, @N(%ptr.loc25_31.2)> [symbolic = %N.type.loc25_32.2 (constants.%N.type.d682d6.3)] // CHECK:STDOUT: %.loc25_33: = impl_self_witness constants.%C, @I, @I(%ptr.loc25_31.2) [symbolic = %.loc25_33 (constants.%.f39)] // CHECK:STDOUT: // CHECK:STDOUT: impl: %C.ref as %N.type.loc25_32.1; @@ -1547,19 +1575,29 @@ impl forall [T: type] D as N(T*) {} // CHECK:STDOUT: %I.type => constants.%I.type.184 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @N.WithSelf(constants.%T, constants.%C) [identified] { +// CHECK:STDOUT: specific @N.WithSelf(constants.%T, constants.%C):identified { // CHECK:STDOUT: !definition: // CHECK:STDOUT: %T => constants.%T -// CHECK:STDOUT: %I.type => constants.%I.type.184 -// CHECK:STDOUT: %require_complete => constants.%require_complete.abf +// CHECK:STDOUT: %I.type => constants.%I.type.d5d +// CHECK:STDOUT: %require_complete => constants.%require_complete.bb5 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @N.WithSelf.Self.as_type.impls.I.type.require(constants.%T, constants.%C) [identified] { +// CHECK:STDOUT: specific @I(constants.%T):identified { +// CHECK:STDOUT: %T.patt => constants.%T.patt // CHECK:STDOUT: %T => constants.%T -// CHECK:STDOUT: %N.type => constants.%N.type.d682d6.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @N.WithSelf.Self.as_type.impls.I.type.require(constants.%T, constants.%C):identified { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %N.type => constants.%N.type.d682d6.2 // CHECK:STDOUT: %Self => constants.%C // CHECK:STDOUT: %Self.as_type => constants.%C -// CHECK:STDOUT: %I.type => constants.%I.type.184 +// CHECK:STDOUT: %I.type => constants.%I.type.d5d +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @N(constants.%T):identified { +// CHECK:STDOUT: %T.patt => constants.%T.patt +// CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @C.as.I.impl.042f52.1(constants.%T) { @@ -1574,26 +1612,36 @@ impl forall [T: type] D as N(T*) {} // CHECK:STDOUT: %T => constants.%ptr // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @N.WithSelf(constants.%ptr, constants.%C) [identified] { +// CHECK:STDOUT: specific @N.WithSelf(constants.%ptr, constants.%C):identified { // CHECK:STDOUT: !definition: // CHECK:STDOUT: %T => constants.%ptr -// CHECK:STDOUT: %I.type => constants.%I.type.751 -// CHECK:STDOUT: %require_complete => constants.%require_complete.d61 +// CHECK:STDOUT: %I.type => constants.%I.type.97e +// CHECK:STDOUT: %require_complete => constants.%require_complete.bfd // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @N.WithSelf.Self.as_type.impls.I.type.require(constants.%ptr, constants.%C) [identified] { +// CHECK:STDOUT: specific @I(constants.%ptr):identified { +// CHECK:STDOUT: %T.patt => constants.%T.patt // CHECK:STDOUT: %T => constants.%ptr -// CHECK:STDOUT: %N.type => constants.%N.type.d682d6.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @N.WithSelf.Self.as_type.impls.I.type.require(constants.%ptr, constants.%C):identified { +// CHECK:STDOUT: %T => constants.%ptr +// CHECK:STDOUT: %N.type => constants.%N.type.d682d6.4 // CHECK:STDOUT: %Self => constants.%C // CHECK:STDOUT: %Self.as_type => constants.%C -// CHECK:STDOUT: %I.type => constants.%I.type.751 +// CHECK:STDOUT: %I.type => constants.%I.type.97e +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @N(constants.%ptr):identified { +// CHECK:STDOUT: %T.patt => constants.%T.patt +// CHECK:STDOUT: %T => constants.%ptr // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @C.as.I.impl.042f52.2(constants.%T) { // CHECK:STDOUT: %T.patt.loc25_15.2 => constants.%T.patt // CHECK:STDOUT: %T.loc25_15.2 => constants.%T // CHECK:STDOUT: %ptr.loc25_31.2 => constants.%ptr -// CHECK:STDOUT: %N.type.loc25_32.2 => constants.%N.type.d682d6.2 +// CHECK:STDOUT: %N.type.loc25_32.2 => constants.%N.type.d682d6.3 // CHECK:STDOUT: %.loc25_33 => constants.%.f39 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -1831,11 +1879,14 @@ impl forall [T: type] D as N(T*) {} // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self.e1f642.1 [symbolic] // CHECK:STDOUT: %ptr.125: type = ptr_type %ptr.e8f [symbolic] // CHECK:STDOUT: %N.type.d682d6.2: type = facet_type <@N, @N(%ptr.125)> [symbolic] -// CHECK:STDOUT: %I.type.539: type = facet_type <@I, @I(%ptr.125)> [symbolic] -// CHECK:STDOUT: %require_complete.776: = require_complete_type %I.type.539 [symbolic] +// CHECK:STDOUT: %I.type.1c0: type = facet_type <@I, @I(%ptr.125):identified> [symbolic] +// CHECK:STDOUT: %require_complete.d22: = require_complete_type %I.type.1c0 [symbolic] +// CHECK:STDOUT: %N.type.d682d6.3: type = facet_type <@N, @N(%ptr.125):identified> [symbolic] // CHECK:STDOUT: %.27c: = impl_self_witness %C, @I, @I(%ptr.125) [symbolic] // CHECK:STDOUT: %I.impl_witness.3cb: = impl_witness @C.as.I.impl.042.%I.impl_witness_table, @C.as.I.impl.042(%T) [symbolic] // CHECK:STDOUT: %Self.e1f642.2: %N.type.d682d6.2 = symbolic_binding Self, 1 [symbolic] +// CHECK:STDOUT: %I.type.539: type = facet_type <@I, @I(%ptr.125)> [symbolic] +// CHECK:STDOUT: %require_complete.776: = require_complete_type %I.type.539 [symbolic] // CHECK:STDOUT: %require_complete.533: = require_complete_type %N.type.d682d6.2 [symbolic] // CHECK:STDOUT: %I.facet.869: %I.type.539 = facet_value %C, (%I.impl_witness.3cb) [symbolic] // CHECK:STDOUT: } @@ -2087,11 +2138,29 @@ impl forall [T: type] D as N(T*) {} // CHECK:STDOUT: %Self => constants.%Self.e1f642.2 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @N.WithSelf(constants.%ptr.125, constants.%C) [identified] { +// CHECK:STDOUT: specific @N.WithSelf(constants.%ptr.125, constants.%C):identified { // CHECK:STDOUT: !definition: // CHECK:STDOUT: %T => constants.%ptr.125 -// CHECK:STDOUT: %I.type => constants.%I.type.539 -// CHECK:STDOUT: %require_complete => constants.%require_complete.776 +// CHECK:STDOUT: %I.type => constants.%I.type.1c0 +// CHECK:STDOUT: %require_complete => constants.%require_complete.d22 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @I(constants.%ptr.125):identified { +// CHECK:STDOUT: %T.patt => constants.%T.patt +// CHECK:STDOUT: %T => constants.%ptr.125 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @N.WithSelf.Self.as_type.impls.I.type.require(constants.%ptr.125, constants.%C):identified { +// CHECK:STDOUT: %T => constants.%ptr.125 +// CHECK:STDOUT: %N.type => constants.%N.type.d682d6.3 +// CHECK:STDOUT: %Self => constants.%C +// CHECK:STDOUT: %Self.as_type => constants.%C +// CHECK:STDOUT: %I.type => constants.%I.type.1c0 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @N(constants.%ptr.125):identified { +// CHECK:STDOUT: %T.patt => constants.%T.patt +// CHECK:STDOUT: %T => constants.%ptr.125 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @I(constants.%ptr.125) { @@ -2099,14 +2168,6 @@ impl forall [T: type] D as N(T*) {} // CHECK:STDOUT: %T => constants.%ptr.125 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @N.WithSelf.Self.as_type.impls.I.type.require(constants.%ptr.125, constants.%C) [identified] { -// CHECK:STDOUT: %T => constants.%ptr.125 -// CHECK:STDOUT: %N.type => constants.%N.type.d682d6.2 -// CHECK:STDOUT: %Self => constants.%C -// CHECK:STDOUT: %Self.as_type => constants.%C -// CHECK:STDOUT: %I.type => constants.%I.type.539 -// CHECK:STDOUT: } -// CHECK:STDOUT: // CHECK:STDOUT: specific @C.as.I.impl.042(constants.%T) { // CHECK:STDOUT: %T.patt.loc6_15.2 => constants.%T.patt // CHECK:STDOUT: %T.loc6_15.2 => constants.%T @@ -2383,10 +2444,14 @@ impl forall [T: type] D as N(T*) {} // CHECK:STDOUT: %empty_struct: %N.type.b76 = struct_value () [concrete] // CHECK:STDOUT: %N.type.d682d6.1: type = facet_type <@N, @N(%T)> [symbolic] // CHECK:STDOUT: %Self.e1f: %N.type.d682d6.1 = symbolic_binding Self, 1 [symbolic] -// CHECK:STDOUT: %require_complete.bd0: = require_complete_type %J.type.ed5 [symbolic] // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self.e1f [symbolic] -// CHECK:STDOUT: %N.type.d682d6.2: type = facet_type <@N, @N(%ptr)> [symbolic] -// CHECK:STDOUT: %require_complete.3d2: = require_complete_type %J.type.a41 [symbolic] +// CHECK:STDOUT: %J.type.17a: type = facet_type <@J, @J(%T):identified> [symbolic] +// CHECK:STDOUT: %require_complete.b01: = require_complete_type %J.type.17a [symbolic] +// CHECK:STDOUT: %N.type.d682d6.2: type = facet_type <@N, @N(%T):identified> [symbolic] +// CHECK:STDOUT: %N.type.d682d6.3: type = facet_type <@N, @N(%ptr)> [symbolic] +// CHECK:STDOUT: %J.type.31c: type = facet_type <@J, @J(%ptr):identified> [symbolic] +// CHECK:STDOUT: %require_complete.9f3: = require_complete_type %J.type.31c [symbolic] +// CHECK:STDOUT: %N.type.d682d6.4: type = facet_type <@N, @N(%ptr):identified> [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -2501,7 +2566,7 @@ impl forall [T: type] D as N(T*) {} // CHECK:STDOUT: %N.ref: %N.type.b76 = name_ref N, imports.%Main.N [concrete = constants.%empty_struct] // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc26_15.1 [symbolic = %T.loc26_15.2 (constants.%T)] // CHECK:STDOUT: %ptr.loc26_31.1: type = ptr_type %T.ref [symbolic = %ptr.loc26_31.2 (constants.%ptr)] -// CHECK:STDOUT: %N.type.loc26_32.1: type = facet_type <@N, @N(constants.%ptr)> [symbolic = %N.type.loc26_32.2 (constants.%N.type.d682d6.2)] +// CHECK:STDOUT: %N.type.loc26_32.1: type = facet_type <@N, @N(constants.%ptr)> [symbolic = %N.type.loc26_32.2 (constants.%N.type.d682d6.3)] // CHECK:STDOUT: %.loc26_17.1: type = splice_block %.loc26_17.2 [concrete = type] { // CHECK:STDOUT: %.Self.frozen: type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen] // CHECK:STDOUT: %.loc26_17.2: type = type_literal type [concrete = type] @@ -2646,7 +2711,7 @@ impl forall [T: type] D as N(T*) {} // CHECK:STDOUT: %T.patt.loc26_15.2: %pattern_type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc26_15.2 (constants.%T.patt)] // CHECK:STDOUT: %T.loc26_15.2: type = symbolic_binding T, 0 [symbolic = %T.loc26_15.2 (constants.%T)] // CHECK:STDOUT: %ptr.loc26_31.2: type = ptr_type %T.loc26_15.2 [symbolic = %ptr.loc26_31.2 (constants.%ptr)] -// CHECK:STDOUT: %N.type.loc26_32.2: type = facet_type <@N, @N(%ptr.loc26_31.2)> [symbolic = %N.type.loc26_32.2 (constants.%N.type.d682d6.2)] +// CHECK:STDOUT: %N.type.loc26_32.2: type = facet_type <@N, @N(%ptr.loc26_31.2)> [symbolic = %N.type.loc26_32.2 (constants.%N.type.d682d6.3)] // CHECK:STDOUT: %.loc26_34: = impl_self_witness constants.%D, @J, @J(%ptr.loc26_31.2) [symbolic = %.loc26_34 (constants.%.d76)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: @@ -2745,19 +2810,29 @@ impl forall [T: type] D as N(T*) {} // CHECK:STDOUT: %J.type => constants.%J.type.ed5 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @N.WithSelf(constants.%T, constants.%D) [identified] { +// CHECK:STDOUT: specific @N.WithSelf(constants.%T, constants.%D):identified { // CHECK:STDOUT: !definition: // CHECK:STDOUT: %T => constants.%T -// CHECK:STDOUT: %J.type => constants.%J.type.ed5 -// CHECK:STDOUT: %require_complete => constants.%require_complete.bd0 +// CHECK:STDOUT: %J.type => constants.%J.type.17a +// CHECK:STDOUT: %require_complete => constants.%require_complete.b01 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @N.WithSelf.Self.as_type.impls.J.type.require(constants.%T, constants.%D) [identified] { +// CHECK:STDOUT: specific @J(constants.%T):identified { +// CHECK:STDOUT: %T.patt => constants.%T.patt // CHECK:STDOUT: %T => constants.%T -// CHECK:STDOUT: %N.type => constants.%N.type.d682d6.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @N.WithSelf.Self.as_type.impls.J.type.require(constants.%T, constants.%D):identified { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %N.type => constants.%N.type.d682d6.2 // CHECK:STDOUT: %Self => constants.%D // CHECK:STDOUT: %Self.as_type => constants.%D -// CHECK:STDOUT: %J.type => constants.%J.type.ed5 +// CHECK:STDOUT: %J.type => constants.%J.type.17a +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @N(constants.%T):identified { +// CHECK:STDOUT: %T.patt => constants.%T.patt +// CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @D.as.J.impl.d69d6f.1(constants.%T) { @@ -2772,26 +2847,36 @@ impl forall [T: type] D as N(T*) {} // CHECK:STDOUT: %T => constants.%ptr // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @N.WithSelf(constants.%ptr, constants.%D) [identified] { +// CHECK:STDOUT: specific @N.WithSelf(constants.%ptr, constants.%D):identified { // CHECK:STDOUT: !definition: // CHECK:STDOUT: %T => constants.%ptr -// CHECK:STDOUT: %J.type => constants.%J.type.a41 -// CHECK:STDOUT: %require_complete => constants.%require_complete.3d2 +// CHECK:STDOUT: %J.type => constants.%J.type.31c +// CHECK:STDOUT: %require_complete => constants.%require_complete.9f3 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @N.WithSelf.Self.as_type.impls.J.type.require(constants.%ptr, constants.%D) [identified] { +// CHECK:STDOUT: specific @J(constants.%ptr):identified { +// CHECK:STDOUT: %T.patt => constants.%T.patt // CHECK:STDOUT: %T => constants.%ptr -// CHECK:STDOUT: %N.type => constants.%N.type.d682d6.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @N.WithSelf.Self.as_type.impls.J.type.require(constants.%ptr, constants.%D):identified { +// CHECK:STDOUT: %T => constants.%ptr +// CHECK:STDOUT: %N.type => constants.%N.type.d682d6.4 // CHECK:STDOUT: %Self => constants.%D // CHECK:STDOUT: %Self.as_type => constants.%D -// CHECK:STDOUT: %J.type => constants.%J.type.a41 +// CHECK:STDOUT: %J.type => constants.%J.type.31c +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @N(constants.%ptr):identified { +// CHECK:STDOUT: %T.patt => constants.%T.patt +// CHECK:STDOUT: %T => constants.%ptr // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @D.as.J.impl.d69d6f.2(constants.%T) { // CHECK:STDOUT: %T.patt.loc26_15.2 => constants.%T.patt // CHECK:STDOUT: %T.loc26_15.2 => constants.%T // CHECK:STDOUT: %ptr.loc26_31.2 => constants.%ptr -// CHECK:STDOUT: %N.type.loc26_32.2 => constants.%N.type.d682d6.2 +// CHECK:STDOUT: %N.type.loc26_32.2 => constants.%N.type.d682d6.3 // CHECK:STDOUT: %.loc26_34 => constants.%.d76 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/incomplete.carbon b/toolchain/check/testdata/impl/incomplete.carbon index f90a7b8b5f3c..c27d64c1d256 100644 --- a/toolchain/check/testdata/impl/incomplete.carbon +++ b/toolchain/check/testdata/impl/incomplete.carbon @@ -1087,11 +1087,11 @@ interface B { // CHECK:STDOUT: !definition: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @Y.WithSelf(constants.%Self.b43) [identified] { +// CHECK:STDOUT: specific @Y.WithSelf(constants.%Self.b43):identified { // CHECK:STDOUT: !definition: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @Y.WithSelf.Self.as_type.impls.Z.type.require(constants.%Self.b43) [identified] { +// CHECK:STDOUT: specific @Y.WithSelf.Self.as_type.impls.Z.type.require(constants.%Self.b43):identified { // CHECK:STDOUT: %Self => constants.%Self.b43 // CHECK:STDOUT: %Self.as_type.loc6_11.2 => constants.%Self.as_type.ace // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/named_constraint/empty_generic.carbon b/toolchain/check/testdata/named_constraint/empty_generic.carbon index 13ba8f357f7c..c9a9b5016c9f 100644 --- a/toolchain/check/testdata/named_constraint/empty_generic.carbon +++ b/toolchain/check/testdata/named_constraint/empty_generic.carbon @@ -267,7 +267,7 @@ fn G(generic T: Z, generic U: Empty(T), generic V: type) { // CHECK:STDOUT: %V.loc20_50.1 => constants.%V // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @Empty.WithSelf(constants.%T.as_type, constants.%empty_struct_type) [identified] { +// CHECK:STDOUT: specific @Empty.WithSelf(constants.%T.as_type, constants.%empty_struct_type):identified { // CHECK:STDOUT: !definition: // CHECK:STDOUT: } // CHECK:STDOUT: @@ -282,7 +282,7 @@ fn G(generic T: Z, generic U: Empty(T), generic V: type) { // CHECK:STDOUT: !definition: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @Empty.WithSelf(constants.%T.as_type, type) [identified] { +// CHECK:STDOUT: specific @Empty.WithSelf(constants.%T.as_type, type):identified { // CHECK:STDOUT: !definition: // CHECK:STDOUT: } // CHECK:STDOUT: @@ -297,7 +297,7 @@ fn G(generic T: Z, generic U: Empty(T), generic V: type) { // CHECK:STDOUT: !definition: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @Empty.WithSelf(constants.%T.as_type, constants.%T.013) [identified] { +// CHECK:STDOUT: specific @Empty.WithSelf(constants.%T.as_type, constants.%T.013):identified { // CHECK:STDOUT: !definition: // CHECK:STDOUT: } // CHECK:STDOUT: @@ -323,7 +323,7 @@ fn G(generic T: Z, generic U: Empty(T), generic V: type) { // CHECK:STDOUT: !definition: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @Empty.WithSelf(constants.%T.as_type, constants.%V) [identified] { +// CHECK:STDOUT: specific @Empty.WithSelf(constants.%T.as_type, constants.%V):identified { // CHECK:STDOUT: !definition: // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/named_constraint/require.carbon b/toolchain/check/testdata/named_constraint/require.carbon index 7e930681e506..2dc7c3be3468 100644 --- a/toolchain/check/testdata/named_constraint/require.carbon +++ b/toolchain/check/testdata/named_constraint/require.carbon @@ -815,11 +815,11 @@ constraint N { // CHECK:STDOUT: !definition: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @Z.WithSelf(constants.%T) [identified] { +// CHECK:STDOUT: specific @Z.WithSelf(constants.%T):identified { // CHECK:STDOUT: !definition: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @Z.WithSelf.Self.as_type.impls.Y.type.require(constants.%T) [identified] { +// CHECK:STDOUT: specific @Z.WithSelf.Self.as_type.impls.Y.type.require(constants.%T):identified { // CHECK:STDOUT: %Self => constants.%T // CHECK:STDOUT: %Self.as_type.loc9_18.2 => constants.%T.as_type // CHECK:STDOUT: } @@ -850,6 +850,8 @@ constraint N { // CHECK:STDOUT: %require_complete.331: = require_complete_type %Y.type.a55 [symbolic] // CHECK:STDOUT: %Y.assoc_type.18b: type = assoc_entity_type @Y, @Y(%T.as_type) [symbolic] // CHECK:STDOUT: %assoc0.eff: %Y.assoc_type.18b = assoc_entity element0, @Y.WithSelf.%Y.WithSelf.YY.decl [symbolic] +// CHECK:STDOUT: %Y.type.7e4: type = facet_type <@Y, @Y(%T.as_type):identified> [symbolic] +// CHECK:STDOUT: %require_complete.aa7: = require_complete_type %Y.type.7e4 [symbolic] // CHECK:STDOUT: %Y.lookup_impl_witness: = lookup_impl_witness %T.f45, @Y, @Y(%T.as_type) [symbolic] // CHECK:STDOUT: %Y.facet: %Y.type.a55 = facet_value %T.as_type, (%Y.lookup_impl_witness) [symbolic] // CHECK:STDOUT: %Y.WithSelf.YY.type.e81: type = fn_type @Y.WithSelf.YY, @Y.WithSelf(%T.as_type, %Y.facet) [symbolic] @@ -979,18 +981,18 @@ constraint N { // CHECK:STDOUT: %require_complete => constants.%require_complete.331 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @Z.WithSelf(constants.%T.f45) [identified] { +// CHECK:STDOUT: specific @Z.WithSelf(constants.%T.f45):identified { // CHECK:STDOUT: !definition: // CHECK:STDOUT: %Self => constants.%T.f45 // CHECK:STDOUT: %Self.as_type => constants.%T.as_type -// CHECK:STDOUT: %Y.type => constants.%Y.type.a55 -// CHECK:STDOUT: %require_complete => constants.%require_complete.331 +// CHECK:STDOUT: %Y.type => constants.%Y.type.7e4 +// CHECK:STDOUT: %require_complete => constants.%require_complete.aa7 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @Z.WithSelf.Self.as_type.impls.Y.type.require(constants.%T.f45) [identified] { +// CHECK:STDOUT: specific @Z.WithSelf.Self.as_type.impls.Y.type.require(constants.%T.f45):identified { // CHECK:STDOUT: %Self => constants.%T.f45 // CHECK:STDOUT: %Self.as_type.loc9_18.2 => constants.%T.as_type -// CHECK:STDOUT: %Y.type.loc9_30.2 => constants.%Y.type.a55 +// CHECK:STDOUT: %Y.type.loc9_30.2 => constants.%Y.type.7e4 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- implicit_self_impls.carbon @@ -1044,11 +1046,11 @@ constraint N { // CHECK:STDOUT: %Self.as_type.loc9_11.2 => constants.%Self.as_type // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @Z.WithSelf(constants.%T) [identified] { +// CHECK:STDOUT: specific @Z.WithSelf(constants.%T):identified { // CHECK:STDOUT: !definition: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @Z.WithSelf.Self.as_type.impls.Y.type.require(constants.%T) [identified] { +// CHECK:STDOUT: specific @Z.WithSelf.Self.as_type.impls.Y.type.require(constants.%T):identified { // CHECK:STDOUT: %Self => constants.%T // CHECK:STDOUT: %Self.as_type.loc9_11.2 => constants.%T.as_type // CHECK:STDOUT: } @@ -1106,11 +1108,11 @@ constraint N { // CHECK:STDOUT: %Self.as_type.loc9_11.2 => constants.%Self.as_type // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @Z.WithSelf(constants.%T) [identified] { +// CHECK:STDOUT: specific @Z.WithSelf(constants.%T):identified { // CHECK:STDOUT: !definition: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @Z.WithSelf.Self.as_type.impls.Y.type.require(constants.%T) [identified] { +// CHECK:STDOUT: specific @Z.WithSelf.Self.as_type.impls.Y.type.require(constants.%T):identified { // CHECK:STDOUT: %Self => constants.%T // CHECK:STDOUT: %Self.as_type.loc9_11.2 => constants.%T.as_type // CHECK:STDOUT: } @@ -1254,7 +1256,7 @@ constraint N { // CHECK:STDOUT: // CHECK:STDOUT: specific @Z.WithSelf(constants.%Self.d87) {} // CHECK:STDOUT: -// CHECK:STDOUT: specific @Z.WithSelf(constants.%Self.d87) [identified] {} +// CHECK:STDOUT: specific @Z.WithSelf(constants.%Self.d87):identified {} // CHECK:STDOUT: // CHECK:STDOUT: specific @Z.WithSelf.Self.as_type.impls.Y_where.type.require(constants.%Self.d87) { // CHECK:STDOUT: %Self => constants.%Self.d87 @@ -1425,7 +1427,7 @@ constraint N { // CHECK:STDOUT: // CHECK:STDOUT: specific @Z.WithSelf(constants.%Self.d87) {} // CHECK:STDOUT: -// CHECK:STDOUT: specific @Z.WithSelf(constants.%Self.d87) [identified] {} +// CHECK:STDOUT: specific @Z.WithSelf(constants.%Self.d87):identified {} // CHECK:STDOUT: // CHECK:STDOUT: specific @Z.WithSelf.Self.as_type.impls.Y_where.type.require(constants.%Self.d87) { // CHECK:STDOUT: %Self => constants.%Self.d87 @@ -1458,7 +1460,7 @@ constraint N { // CHECK:STDOUT: %facet_type.e5c: type = facet_type <@Z & @Y, @Y(%.Self.c86)> [symbolic_self] // CHECK:STDOUT: %T.d09: %facet_type.e5c = symbolic_binding T, 0 [symbolic] // CHECK:STDOUT: %T.as_type: type = facet_access_type %T.d09 [symbolic] -// CHECK:STDOUT: %Z_where.type.bfc: type = facet_type <@Z where .Self impls @Y, @Y(%T.as_type)> [symbolic] +// CHECK:STDOUT: %Z_where.type.8a6: type = facet_type <@Z where .Self impls @Y, @Y(%T.as_type):identified> [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -1526,14 +1528,14 @@ constraint N { // CHECK:STDOUT: %Z_where.type.loc10_19.2 => constants.%Z_where.type.e7d // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @N.WithSelf(constants.%T.d09) [identified] { +// CHECK:STDOUT: specific @N.WithSelf(constants.%T.d09):identified { // CHECK:STDOUT: !definition: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @N.WithSelf.Self.as_type.impls.Z_where.type.require(constants.%T.d09) [identified] { +// CHECK:STDOUT: specific @N.WithSelf.Self.as_type.impls.Z_where.type.require(constants.%T.d09):identified { // CHECK:STDOUT: %Self => constants.%T.d09 // CHECK:STDOUT: %Self.as_type.loc10_11.2 => constants.%T.as_type -// CHECK:STDOUT: %Z_where.type.loc10_19.2 => constants.%Z_where.type.bfc +// CHECK:STDOUT: %Z_where.type.loc10_19.2 => constants.%Z_where.type.8a6 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- require_with_specific_period_self.carbon @@ -1558,11 +1560,11 @@ constraint N { // CHECK:STDOUT: %Y.type.23e: type = facet_type <@Y, @Y(%.Self.as_type)> [symbolic_self] // CHECK:STDOUT: %Z_where.type.a0f3c6.1: type = facet_type <@Z where %C.cf2 impls @Y, @Y(%.Self.as_type)> [concrete] // CHECK:STDOUT: %C.f15: type = class_type @C, @C(%Self.as_type) [symbolic] -// CHECK:STDOUT: %Z_where.type.a0f3c6.2: type = facet_type <@Z where %C.f15 impls @Y, @Y(%Self.as_type)> [symbolic] +// CHECK:STDOUT: %Z_where.type.a0f3c6.3: type = facet_type <@Z where %C.f15 impls @Y, @Y(%Self.as_type)> [symbolic] // CHECK:STDOUT: %T.013: %Z.type = symbolic_binding T, 0 [symbolic] // CHECK:STDOUT: %T.as_type: type = facet_access_type %T.013 [symbolic] -// CHECK:STDOUT: %C.7b3: type = class_type @C, @C(%T.as_type) [symbolic] -// CHECK:STDOUT: %Z_where.type.a0f3c6.3: type = facet_type <@Z where %C.7b3 impls @Y, @Y(%T.as_type)> [symbolic] +// CHECK:STDOUT: %C.f24: type = class_type @C, @C(%T.as_type):identified [symbolic] +// CHECK:STDOUT: %Z_where.type.a0f3c6.4: type = facet_type <@Z where %C.f24 impls @Y, @Y(%T.as_type):identified> [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -1599,7 +1601,7 @@ constraint N { // CHECK:STDOUT: %base_facet_type = requirement_base_facet_type %Z.ref [concrete] // CHECK:STDOUT: %impls.loc10_34.2 = requirement_impls %C.loc10_32.2, %Y.type.loc10_47.2 [concrete] // CHECK:STDOUT: } -// CHECK:STDOUT: %Z_where.type.loc10_19.1: type = facet_type <@Z where constants.%C.f15 impls @Y, @Y(constants.%Self.as_type)> [symbolic = %Z_where.type.loc10_19.2 (constants.%Z_where.type.a0f3c6.2)] +// CHECK:STDOUT: %Z_where.type.loc10_19.1: type = facet_type <@Z where constants.%C.f15 impls @Y, @Y(constants.%Self.as_type)> [symbolic = %Z_where.type.loc10_19.2 (constants.%Z_where.type.a0f3c6.3)] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: !members: @@ -1621,7 +1623,7 @@ constraint N { // CHECK:STDOUT: %Self: %N.type = symbolic_binding Self, 0 [symbolic = %Self (constants.%Self.d87)] // CHECK:STDOUT: %Self.as_type.loc10_11.2: type = facet_access_type %Self [symbolic = %Self.as_type.loc10_11.2 (constants.%Self.as_type)] // CHECK:STDOUT: %C.loc10_19: type = class_type @C, @C(%Self.as_type.loc10_11.2) [symbolic = %C.loc10_19 (constants.%C.f15)] -// CHECK:STDOUT: %Z_where.type.loc10_19.2: type = facet_type <@Z where %C.loc10_19 impls @Y, @Y(%Self.as_type.loc10_11.2)> [symbolic = %Z_where.type.loc10_19.2 (constants.%Z_where.type.a0f3c6.2)] +// CHECK:STDOUT: %Z_where.type.loc10_19.2: type = facet_type <@Z where %C.loc10_19 impls @Y, @Y(%Self.as_type.loc10_11.2)> [symbolic = %Z_where.type.loc10_19.2 (constants.%Z_where.type.a0f3c6.3)] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @N.WithSelf(constants.%Self.d87) {} @@ -1630,17 +1632,17 @@ constraint N { // CHECK:STDOUT: %Self => constants.%Self.d87 // CHECK:STDOUT: %Self.as_type.loc10_11.2 => constants.%Self.as_type // CHECK:STDOUT: %C.loc10_19 => constants.%C.f15 -// CHECK:STDOUT: %Z_where.type.loc10_19.2 => constants.%Z_where.type.a0f3c6.2 -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: specific @N.WithSelf(constants.%T.013) [identified] { -// CHECK:STDOUT: !definition: -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: specific @N.WithSelf.Self.as_type.impls.Z_where.type.require(constants.%T.013) [identified] { -// CHECK:STDOUT: %Self => constants.%T.013 -// CHECK:STDOUT: %Self.as_type.loc10_11.2 => constants.%T.as_type -// CHECK:STDOUT: %C.loc10_19 => constants.%C.7b3 // CHECK:STDOUT: %Z_where.type.loc10_19.2 => constants.%Z_where.type.a0f3c6.3 // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @N.WithSelf(constants.%T.013):identified { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @N.WithSelf.Self.as_type.impls.Z_where.type.require(constants.%T.013):identified { +// CHECK:STDOUT: %Self => constants.%T.013 +// CHECK:STDOUT: %Self.as_type.loc10_11.2 => constants.%T.as_type +// CHECK:STDOUT: %C.loc10_19 => constants.%C.f24 +// CHECK:STDOUT: %Z_where.type.loc10_19.2 => constants.%Z_where.type.a0f3c6.4 +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/type_completion.cpp b/toolchain/check/type_completion.cpp index 6c0fd3f03e1d..ee1a80de4199 100644 --- a/toolchain/check/type_completion.cpp +++ b/toolchain/check/type_completion.cpp @@ -1116,8 +1116,7 @@ static auto IdentifyFacetType(Context& context, SemIR::LocId loc_id, auto constraint_with_self_specific_id = MakeSpecificWithInnerSelf( context, loc_id, constraint.generic_id, - constraint.generic_with_self_id, extends.specific_id, self_const_id, - /*make_identified_specific=*/true); + constraint.generic_with_self_id, extends.specific_id, self_const_id); if (context.specifics().HasError(constraint_with_self_specific_id)) { return SemIR::IdentifiedFacetTypeId::None; } @@ -1130,8 +1129,7 @@ static auto IdentifyFacetType(Context& context, SemIR::LocId loc_id, // instantiated. auto require_specific_id = CopySpecificToGeneric( context, SemIR::LocId(require.decl_id), - constraint_with_self_specific_id, require.generic_id, - /*make_identified_specific=*/true); + constraint_with_self_specific_id, require.generic_id); auto require_self = GetConstantValueInSpecific( context.sem_ir(), require_specific_id, require.self_id); auto require_facet_type = GetConstantValueInSpecific( @@ -1175,8 +1173,7 @@ static auto IdentifyFacetType(Context& context, SemIR::LocId loc_id, auto constraint_with_self_specific_id = MakeSpecificWithInnerSelf( context, loc_id, constraint.generic_id, - constraint.generic_with_self_id, impls.specific_id, self_const_id, - /*make_identified_specific=*/true); + constraint.generic_with_self_id, impls.specific_id, self_const_id); if (context.specifics().HasError(constraint_with_self_specific_id)) { return SemIR::IdentifiedFacetTypeId::None; } @@ -1189,8 +1186,7 @@ static auto IdentifyFacetType(Context& context, SemIR::LocId loc_id, // instantiated. auto require_specific_id = CopySpecificToGeneric( context, SemIR::LocId(require.decl_id), - constraint_with_self_specific_id, require.generic_id, - /*make_identified_specific=*/true); + constraint_with_self_specific_id, require.generic_id); auto require_self = GetConstantValueInSpecific( context.sem_ir(), require_specific_id, require.self_id); auto require_facet_type = GetConstantValueInSpecific( @@ -1236,8 +1232,7 @@ static auto IdentifyFacetType(Context& context, SemIR::LocId loc_id, auto constraint_with_self_specific_id = MakeSpecificWithInnerSelf( context, loc_id, constraint.generic_id, constraint.generic_with_self_id, impls.specific_id, - context.constant_values().Get(self_type_inst_id), - /*make_identified_specific=*/true); + context.constant_values().Get(self_type_inst_id)); if (context.specifics().HasError(constraint_with_self_specific_id)) { return SemIR::IdentifiedFacetTypeId::None; } @@ -1250,8 +1245,7 @@ static auto IdentifyFacetType(Context& context, SemIR::LocId loc_id, // instantiated. auto require_specific_id = CopySpecificToGeneric( context, SemIR::LocId(require.decl_id), - constraint_with_self_specific_id, require.generic_id, - /*make_identified_specific=*/true); + constraint_with_self_specific_id, require.generic_id); auto require_self = GetConstantValueInSpecific( context.sem_ir(), require_specific_id, require.self_id); auto require_facet_type = GetConstantValueInSpecific( diff --git a/toolchain/sem_ir/formatter.cpp b/toolchain/sem_ir/formatter.cpp index 90835a1b2854..bc2cbbb54f6c 100644 --- a/toolchain/sem_ir/formatter.cpp +++ b/toolchain/sem_ir/formatter.cpp @@ -691,9 +691,6 @@ auto Formatter::FormatSpecific(SpecificId id, const Specific& specific) out() << "specific "; FormatName(id); out() << " "; - if (specific.identified) { - out() << "[identified] "; - } OpenBrace(); FormatSpecificRegion(generic, specific, GenericInstIndex::Region::Declaration, @@ -1765,6 +1762,9 @@ auto Formatter::FormatName(SpecificId id) -> void { const auto& specific = sem_ir_->specifics().Get(id); FormatName(specific.generic_id); FormatArg(specific.args_id); + if (specific.identified) { + out() << ":identified"; + } } auto Formatter::FormatName(SpecificInterfaceId id) -> void {