mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
This also does a little restructuring in the same direction, following #6124. Leads want `Destroy` to work similarly now for all types. As a consequence, there doesn't seem to be as much benefit to splitting off aggregate destruction. In this PR, the `type.destroy` function can now be expected to destroy anything that's destructible; that means it'll be usable for the `final fn` once that support is available. Similarly, this gets rid of the impls other than the single blanket impl, now using `type.can_destroy`. Since they all need to use the same function, there's no benefit to splitting approaches. Also, now it can just be a `final impl` since there should be no need for people to create specializations -- if this blanket impl applies, it means the `final fn` is the same. This also slips in `partial` support since there's no reason to have it diverge anymore. Also `abstract`, which I'm not sure is broadly testable since most cases it'd come up, the `abstract` keyword is explicitly detected/rejected. Note though that this doesn't make any really big changes. It's just realigning on the leads decision. I'm going this way to try to reduce name-related churn for other changes.
This commit is contained in:
@@ -165,10 +165,10 @@ fn Call() {
|
||||
// CHECK:STDOUT: %empty_struct.576: %.c13 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %D__carbon_thunk.type: type = fn_type @D__carbon_thunk [concrete]
|
||||
// CHECK:STDOUT: %D__carbon_thunk: %D__carbon_thunk.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanAggregateDestroy>> [concrete]
|
||||
// CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
|
||||
// CHECK:STDOUT: %facet_value: %type_where = facet_value %X, () [concrete]
|
||||
// CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.type.d91: type = fn_type @AggregateT.as_type.as.Destroy.impl.Op, @AggregateT.as_type.as.Destroy.impl(%facet_value) [concrete]
|
||||
// CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.55b: %AggregateT.as_type.as.Destroy.impl.Op.type.d91 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.type.d91: type = fn_type @DestroyT.as_type.as.Destroy.impl.Op, @DestroyT.as_type.as.Destroy.impl(%facet_value) [concrete]
|
||||
// CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.55b: %DestroyT.as_type.as.Destroy.impl.Op.type.d91 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
@@ -321,18 +321,18 @@ fn Call() {
|
||||
// CHECK:STDOUT: %D__carbon_thunk.call: init %empty_tuple.type = call imports.%D__carbon_thunk.decl(%addr.loc11_23, %.loc11_19.2, %.loc11_22.2)
|
||||
// CHECK:STDOUT: %facet_value.loc11: %type_where = facet_value constants.%X, () [concrete = constants.%facet_value]
|
||||
// CHECK:STDOUT: %.loc11_5.5: %type_where = converted constants.%X, %facet_value.loc11 [concrete = constants.%facet_value]
|
||||
// CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.bound.loc11: <bound method> = bound_method %.loc11_5.4, constants.%AggregateT.as_type.as.Destroy.impl.Op.55b
|
||||
// CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.bound.loc11: <bound method> = bound_method %.loc11_5.4, constants.%DestroyT.as_type.as.Destroy.impl.Op.55b
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %bound_method.loc11_5: <bound method> = bound_method %.loc11_5.4, %AggregateT.as_type.as.Destroy.impl.Op.specific_fn.1
|
||||
// CHECK:STDOUT: %bound_method.loc11_5: <bound method> = bound_method %.loc11_5.4, %DestroyT.as_type.as.Destroy.impl.Op.specific_fn.1
|
||||
// CHECK:STDOUT: %addr.loc11_5: %ptr.1f9 = addr_of %.loc11_5.4
|
||||
// CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.call.loc11: init %empty_tuple.type = call %bound_method.loc11_5(%addr.loc11_5)
|
||||
// CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.call.loc11: init %empty_tuple.type = call %bound_method.loc11_5(%addr.loc11_5)
|
||||
// CHECK:STDOUT: %facet_value.loc9: %type_where = facet_value constants.%X, () [concrete = constants.%facet_value]
|
||||
// CHECK:STDOUT: %.loc9_5.5: %type_where = converted constants.%X, %facet_value.loc9 [concrete = constants.%facet_value]
|
||||
// CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.bound.loc9: <bound method> = bound_method %.loc9_5.4, constants.%AggregateT.as_type.as.Destroy.impl.Op.55b
|
||||
// CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.bound.loc9: <bound method> = bound_method %.loc9_5.4, constants.%DestroyT.as_type.as.Destroy.impl.Op.55b
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %bound_method.loc9_5: <bound method> = bound_method %.loc9_5.4, %AggregateT.as_type.as.Destroy.impl.Op.specific_fn.2
|
||||
// CHECK:STDOUT: %bound_method.loc9_5: <bound method> = bound_method %.loc9_5.4, %DestroyT.as_type.as.Destroy.impl.Op.specific_fn.2
|
||||
// CHECK:STDOUT: %addr.loc9_5: %ptr.1f9 = addr_of %.loc9_5.4
|
||||
// CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.call.loc9: init %empty_tuple.type = call %bound_method.loc9_5(%addr.loc9_5)
|
||||
// CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.call.loc9: init %empty_tuple.type = call %bound_method.loc9_5(%addr.loc9_5)
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
@@ -397,11 +397,11 @@ fn Call() {
|
||||
// CHECK:STDOUT: %D__carbon_thunk.type: type = fn_type @D__carbon_thunk [concrete]
|
||||
// CHECK:STDOUT: %D__carbon_thunk: %D__carbon_thunk.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
|
||||
// CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanAggregateDestroy>> [concrete]
|
||||
// CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
|
||||
// CHECK:STDOUT: %facet_value: %type_where = facet_value %X, () [concrete]
|
||||
// CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.type.d91: type = fn_type @AggregateT.as_type.as.Destroy.impl.Op, @AggregateT.as_type.as.Destroy.impl(%facet_value) [concrete]
|
||||
// CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.55b: %AggregateT.as_type.as.Destroy.impl.Op.type.d91 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.specific_fn: <specific function> = specific_function %AggregateT.as_type.as.Destroy.impl.Op.55b, @AggregateT.as_type.as.Destroy.impl.Op(%facet_value) [concrete]
|
||||
// CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.type.d91: type = fn_type @DestroyT.as_type.as.Destroy.impl.Op, @DestroyT.as_type.as.Destroy.impl(%facet_value) [concrete]
|
||||
// CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.55b: %DestroyT.as_type.as.Destroy.impl.Op.type.d91 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.specific_fn: <specific function> = specific_function %DestroyT.as_type.as.Destroy.impl.Op.55b, @DestroyT.as_type.as.Destroy.impl.Op(%facet_value) [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
@@ -643,18 +643,18 @@ fn Call() {
|
||||
// CHECK:STDOUT: %D__carbon_thunk.call: init %empty_tuple.type = call imports.%D__carbon_thunk.decl(%addr.loc12_20, %.loc12_19.2)
|
||||
// CHECK:STDOUT: %facet_value.loc12: %type_where = facet_value constants.%X, () [concrete = constants.%facet_value]
|
||||
// CHECK:STDOUT: %.loc12_5.5: %type_where = converted constants.%X, %facet_value.loc12 [concrete = constants.%facet_value]
|
||||
// CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.bound.loc12: <bound method> = bound_method %.loc12_5.4, constants.%AggregateT.as_type.as.Destroy.impl.Op.55b
|
||||
// CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.specific_fn.1: <specific function> = specific_function constants.%AggregateT.as_type.as.Destroy.impl.Op.55b, @AggregateT.as_type.as.Destroy.impl.Op(constants.%facet_value) [concrete = constants.%AggregateT.as_type.as.Destroy.impl.Op.specific_fn]
|
||||
// CHECK:STDOUT: %bound_method.loc12_5: <bound method> = bound_method %.loc12_5.4, %AggregateT.as_type.as.Destroy.impl.Op.specific_fn.1
|
||||
// CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.bound.loc12: <bound method> = bound_method %.loc12_5.4, constants.%DestroyT.as_type.as.Destroy.impl.Op.55b
|
||||
// CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.specific_fn.1: <specific function> = specific_function constants.%DestroyT.as_type.as.Destroy.impl.Op.55b, @DestroyT.as_type.as.Destroy.impl.Op(constants.%facet_value) [concrete = constants.%DestroyT.as_type.as.Destroy.impl.Op.specific_fn]
|
||||
// CHECK:STDOUT: %bound_method.loc12_5: <bound method> = bound_method %.loc12_5.4, %DestroyT.as_type.as.Destroy.impl.Op.specific_fn.1
|
||||
// CHECK:STDOUT: %addr.loc12_5: %ptr.1f9 = addr_of %.loc12_5.4
|
||||
// CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.call.loc12: init %empty_tuple.type = call %bound_method.loc12_5(%addr.loc12_5)
|
||||
// CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.call.loc12: init %empty_tuple.type = call %bound_method.loc12_5(%addr.loc12_5)
|
||||
// CHECK:STDOUT: %facet_value.loc10: %type_where = facet_value constants.%X, () [concrete = constants.%facet_value]
|
||||
// CHECK:STDOUT: %.loc10_5.5: %type_where = converted constants.%X, %facet_value.loc10 [concrete = constants.%facet_value]
|
||||
// CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.bound.loc10: <bound method> = bound_method %.loc10_5.4, constants.%AggregateT.as_type.as.Destroy.impl.Op.55b
|
||||
// CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.specific_fn.2: <specific function> = specific_function constants.%AggregateT.as_type.as.Destroy.impl.Op.55b, @AggregateT.as_type.as.Destroy.impl.Op(constants.%facet_value) [concrete = constants.%AggregateT.as_type.as.Destroy.impl.Op.specific_fn]
|
||||
// CHECK:STDOUT: %bound_method.loc10_5: <bound method> = bound_method %.loc10_5.4, %AggregateT.as_type.as.Destroy.impl.Op.specific_fn.2
|
||||
// CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.bound.loc10: <bound method> = bound_method %.loc10_5.4, constants.%DestroyT.as_type.as.Destroy.impl.Op.55b
|
||||
// CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.specific_fn.2: <specific function> = specific_function constants.%DestroyT.as_type.as.Destroy.impl.Op.55b, @DestroyT.as_type.as.Destroy.impl.Op(constants.%facet_value) [concrete = constants.%DestroyT.as_type.as.Destroy.impl.Op.specific_fn]
|
||||
// CHECK:STDOUT: %bound_method.loc10_5: <bound method> = bound_method %.loc10_5.4, %DestroyT.as_type.as.Destroy.impl.Op.specific_fn.2
|
||||
// CHECK:STDOUT: %addr.loc10_5: %ptr.1f9 = addr_of %.loc10_5.4
|
||||
// CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.call.loc10: init %empty_tuple.type = call %bound_method.loc10_5(%addr.loc10_5)
|
||||
// CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.call.loc10: init %empty_tuple.type = call %bound_method.loc10_5(%addr.loc10_5)
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
@@ -682,7 +682,7 @@ fn Call() {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
||||
// CHECK:STDOUT: %.490: type = cpp_overload_set_type @const.as.Destroy.impl.Op [concrete]
|
||||
// CHECK:STDOUT: %.490: type = cpp_overload_set_type @<null name> [concrete]
|
||||
// CHECK:STDOUT: %empty_struct.a89: %.490 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
|
||||
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
|
||||
@@ -692,12 +692,12 @@ fn Call() {
|
||||
// CHECK:STDOUT: %empty_struct.61d: %.ed9 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %.ce5: type = cpp_overload_set_type @<null name> [concrete]
|
||||
// CHECK:STDOUT: %empty_struct.a7d: %.ce5 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %.c13: type = cpp_overload_set_type @<null name> [concrete]
|
||||
// CHECK:STDOUT: %.c13: type = cpp_overload_set_type @X [concrete]
|
||||
// CHECK:STDOUT: %empty_struct.576: %.c13 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanAggregateDestroy>> [concrete]
|
||||
// CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
|
||||
// CHECK:STDOUT: %facet_value: %type_where = facet_value %X, () [concrete]
|
||||
// CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.type.d91: type = fn_type @AggregateT.as_type.as.Destroy.impl.Op, @AggregateT.as_type.as.Destroy.impl(%facet_value) [concrete]
|
||||
// CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.55b: %AggregateT.as_type.as.Destroy.impl.Op.type.d91 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.type.d91: type = fn_type @DestroyT.as_type.as.Destroy.impl.Op, @DestroyT.as_type.as.Destroy.impl(%facet_value) [concrete]
|
||||
// CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.55b: %DestroyT.as_type.as.Destroy.impl.Op.type.d91 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %ptr.1f9: type = ptr_type %X [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
@@ -707,11 +707,11 @@ fn Call() {
|
||||
// CHECK:STDOUT: .X = %X.decl
|
||||
// CHECK:STDOUT: import Cpp//...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %.7c0: %.490 = cpp_overload_set_value @const.as.Destroy.impl.Op [concrete = constants.%empty_struct.a89]
|
||||
// CHECK:STDOUT: %.7c0: %.490 = cpp_overload_set_value @<null name> [concrete = constants.%empty_struct.a89]
|
||||
// CHECK:STDOUT: %X.decl: type = class_decl @X [concrete = constants.%X] {} {}
|
||||
// CHECK:STDOUT: %.8ab: %.ed9 = cpp_overload_set_value @<null name> [concrete = constants.%empty_struct.61d]
|
||||
// CHECK:STDOUT: %.7af: %.ce5 = cpp_overload_set_value @<null name> [concrete = constants.%empty_struct.a7d]
|
||||
// CHECK:STDOUT: %.7b7: %.c13 = cpp_overload_set_value @<null name> [concrete = constants.%empty_struct.576]
|
||||
// CHECK:STDOUT: %.7b7: %.c13 = cpp_overload_set_value @X [concrete = constants.%empty_struct.576]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @Call() {
|
||||
@@ -744,18 +744,18 @@ fn Call() {
|
||||
// CHECK:STDOUT: %bound_method.loc56_16: <bound method> = bound_method %.loc56_7, %D.ref
|
||||
// CHECK:STDOUT: %facet_value.loc56: %type_where = facet_value constants.%X, () [concrete = constants.%facet_value]
|
||||
// CHECK:STDOUT: %.loc56_5.5: %type_where = converted constants.%X, %facet_value.loc56 [concrete = constants.%facet_value]
|
||||
// CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.bound.loc56: <bound method> = bound_method %.loc56_5.4, constants.%AggregateT.as_type.as.Destroy.impl.Op.55b
|
||||
// CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.bound.loc56: <bound method> = bound_method %.loc56_5.4, constants.%DestroyT.as_type.as.Destroy.impl.Op.55b
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %bound_method.loc56_5: <bound method> = bound_method %.loc56_5.4, %AggregateT.as_type.as.Destroy.impl.Op.specific_fn.1
|
||||
// CHECK:STDOUT: %bound_method.loc56_5: <bound method> = bound_method %.loc56_5.4, %DestroyT.as_type.as.Destroy.impl.Op.specific_fn.1
|
||||
// CHECK:STDOUT: %addr.loc56: %ptr.1f9 = addr_of %.loc56_5.4
|
||||
// CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.call.loc56: init %empty_tuple.type = call %bound_method.loc56_5(%addr.loc56)
|
||||
// CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.call.loc56: init %empty_tuple.type = call %bound_method.loc56_5(%addr.loc56)
|
||||
// CHECK:STDOUT: %facet_value.loc36: %type_where = facet_value constants.%X, () [concrete = constants.%facet_value]
|
||||
// CHECK:STDOUT: %.loc36_5.5: %type_where = converted constants.%X, %facet_value.loc36 [concrete = constants.%facet_value]
|
||||
// CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.bound.loc36: <bound method> = bound_method %.loc36_5.4, constants.%AggregateT.as_type.as.Destroy.impl.Op.55b
|
||||
// CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.bound.loc36: <bound method> = bound_method %.loc36_5.4, constants.%DestroyT.as_type.as.Destroy.impl.Op.55b
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %bound_method.loc36_5: <bound method> = bound_method %.loc36_5.4, %AggregateT.as_type.as.Destroy.impl.Op.specific_fn.2
|
||||
// CHECK:STDOUT: %bound_method.loc36_5: <bound method> = bound_method %.loc36_5.4, %DestroyT.as_type.as.Destroy.impl.Op.specific_fn.2
|
||||
// CHECK:STDOUT: %addr.loc36: %ptr.1f9 = addr_of %.loc36_5.4
|
||||
// CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.call.loc36: init %empty_tuple.type = call %bound_method.loc36_5(%addr.loc36)
|
||||
// CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.call.loc36: init %empty_tuple.type = call %bound_method.loc36_5(%addr.loc36)
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
|
||||
Reference in New Issue
Block a user