adapt_copy.carbon 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/adapter/adapt_copy.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/adapter/adapt_copy.carbon
  10. // --- adapt_copyable.carbon
  11. library "[[@TEST_NAME]]";
  12. class AdaptCopyable {
  13. adapt i32;
  14. }
  15. // We can copy an adapter by copying its value if its initializing
  16. // representation is a copy of its value representation.
  17. fn F(c: AdaptCopyable) -> AdaptCopyable {
  18. var d: AdaptCopyable = c;
  19. return d;
  20. }
  21. fn InTuple(c: (AdaptCopyable, u32)) -> (AdaptCopyable, u32) {
  22. var d: (AdaptCopyable, u32) = c;
  23. return d;
  24. }
  25. // --- adapt_copyable_tuple.carbon
  26. library "[[@TEST_NAME]]";
  27. class AdaptTuple {
  28. adapt (i32, i32);
  29. }
  30. fn F(c: AdaptTuple) -> AdaptTuple {
  31. var d: AdaptTuple = c;
  32. return d;
  33. }
  34. fn InTuple(c: (AdaptTuple, u32)) -> (AdaptTuple, u32) {
  35. var d: (AdaptTuple, u32) = c;
  36. return d;
  37. }
  38. // --- fail_adapt_not_copyable.carbon
  39. library "[[@TEST_NAME]]";
  40. class Noncopyable {
  41. // TODO: Ensure this remains non-copyable once we have rules for class copyability.
  42. }
  43. class AdaptNoncopyable {
  44. adapt Noncopyable;
  45. }
  46. fn G(a: AdaptNoncopyable) -> AdaptNoncopyable {
  47. // CHECK:STDERR: fail_adapt_not_copyable.carbon:[[@LINE+4]]:29: error: cannot copy value of type `AdaptNoncopyable` [CopyOfUncopyableType]
  48. // CHECK:STDERR: var b: AdaptNoncopyable = a;
  49. // CHECK:STDERR: ^
  50. // CHECK:STDERR:
  51. var b: AdaptNoncopyable = a;
  52. // CHECK:STDERR: fail_adapt_not_copyable.carbon:[[@LINE+4]]:10: error: cannot copy value of type `AdaptNoncopyable` [CopyOfUncopyableType]
  53. // CHECK:STDERR: return b;
  54. // CHECK:STDERR: ^
  55. // CHECK:STDERR:
  56. return b;
  57. }
  58. // --- fail_adapt_not_copyable_indirect.carbon
  59. library "[[@TEST_NAME]]";
  60. class Noncopyable {
  61. // TODO: Ensure this remains non-copyable once we have rules for class copyability.
  62. }
  63. class AdaptNoncopyableIndirect {
  64. adapt (i32, Noncopyable, i32);
  65. }
  66. fn H(a: AdaptNoncopyableIndirect) -> AdaptNoncopyableIndirect {
  67. // CHECK:STDERR: fail_adapt_not_copyable_indirect.carbon:[[@LINE+7]]:3: error: cannot copy value of type `Noncopyable` [CopyOfUncopyableType]
  68. // CHECK:STDERR: var b: AdaptNoncopyableIndirect = a;
  69. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  70. // CHECK:STDERR: fail_adapt_not_copyable_indirect.carbon:[[@LINE+4]]:37: note: in copy of `AdaptNoncopyableIndirect` [InCopy]
  71. // CHECK:STDERR: var b: AdaptNoncopyableIndirect = a;
  72. // CHECK:STDERR: ^
  73. // CHECK:STDERR:
  74. var b: AdaptNoncopyableIndirect = a;
  75. // CHECK:STDERR: fail_adapt_not_copyable_indirect.carbon:[[@LINE+7]]:3: error: cannot copy value of type `Noncopyable` [CopyOfUncopyableType]
  76. // CHECK:STDERR: return b;
  77. // CHECK:STDERR: ^~~~~~~~~
  78. // CHECK:STDERR: fail_adapt_not_copyable_indirect.carbon:[[@LINE+4]]:10: note: in copy of `AdaptNoncopyableIndirect` [InCopy]
  79. // CHECK:STDERR: return b;
  80. // CHECK:STDERR: ^
  81. // CHECK:STDERR:
  82. return b;
  83. }
  84. // --- adapt_copyable_struct.carbon
  85. library "[[@TEST_NAME]]";
  86. class AdaptStruct {
  87. adapt {.e: i32, .f: i32};
  88. }
  89. fn I(g: AdaptStruct) -> AdaptStruct {
  90. var h: AdaptStruct = g;
  91. return h;
  92. }
  93. fn InTuple(c: (AdaptStruct, u32)) -> (AdaptStruct, u32) {
  94. var d: (AdaptStruct, u32) = c;
  95. return d;
  96. }
  97. // CHECK:STDOUT: --- adapt_copyable.carbon
  98. // CHECK:STDOUT:
  99. // CHECK:STDOUT: constants {
  100. // CHECK:STDOUT: %AdaptCopyable: type = class_type @AdaptCopyable [template]
  101. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  102. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  103. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [template]
  104. // CHECK:STDOUT: %complete_type.f8a: <witness> = complete_type_witness %i32.builtin [template]
  105. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  106. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  107. // CHECK:STDOUT: %u32: type = class_type @UInt, @UInt(%int_32) [template]
  108. // CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template]
  109. // CHECK:STDOUT: %tuple.type.2a3: type = tuple_type (%AdaptCopyable, %u32) [template]
  110. // CHECK:STDOUT: %InTuple.type: type = fn_type @InTuple [template]
  111. // CHECK:STDOUT: %InTuple: %InTuple.type = struct_value () [template]
  112. // CHECK:STDOUT: }
  113. // CHECK:STDOUT:
  114. // CHECK:STDOUT: imports {
  115. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  116. // CHECK:STDOUT: .Int = %Core.Int
  117. // CHECK:STDOUT: .UInt = %Core.UInt
  118. // CHECK:STDOUT: import Core//prelude
  119. // CHECK:STDOUT: import Core//prelude/...
  120. // CHECK:STDOUT: }
  121. // CHECK:STDOUT: }
  122. // CHECK:STDOUT:
  123. // CHECK:STDOUT: file {
  124. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  125. // CHECK:STDOUT: .Core = imports.%Core
  126. // CHECK:STDOUT: .AdaptCopyable = %AdaptCopyable.decl
  127. // CHECK:STDOUT: .F = %F.decl
  128. // CHECK:STDOUT: .InTuple = %InTuple.decl
  129. // CHECK:STDOUT: }
  130. // CHECK:STDOUT: %Core.import = import Core
  131. // CHECK:STDOUT: %AdaptCopyable.decl: type = class_decl @AdaptCopyable [template = constants.%AdaptCopyable] {} {}
  132. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  133. // CHECK:STDOUT: %c.patt: %AdaptCopyable = binding_pattern c
  134. // CHECK:STDOUT: %c.param_patt: %AdaptCopyable = value_param_pattern %c.patt, runtime_param0
  135. // CHECK:STDOUT: %return.patt: %AdaptCopyable = return_slot_pattern
  136. // CHECK:STDOUT: %return.param_patt: %AdaptCopyable = out_param_pattern %return.patt, runtime_param1
  137. // CHECK:STDOUT: } {
  138. // CHECK:STDOUT: %AdaptCopyable.ref.loc10_27: type = name_ref AdaptCopyable, file.%AdaptCopyable.decl [template = constants.%AdaptCopyable]
  139. // CHECK:STDOUT: %c.param: %AdaptCopyable = value_param runtime_param0
  140. // CHECK:STDOUT: %AdaptCopyable.ref.loc10_9: type = name_ref AdaptCopyable, file.%AdaptCopyable.decl [template = constants.%AdaptCopyable]
  141. // CHECK:STDOUT: %c: %AdaptCopyable = bind_name c, %c.param
  142. // CHECK:STDOUT: %return.param: ref %AdaptCopyable = out_param runtime_param1
  143. // CHECK:STDOUT: %return: ref %AdaptCopyable = return_slot %return.param
  144. // CHECK:STDOUT: }
  145. // CHECK:STDOUT: %InTuple.decl: %InTuple.type = fn_decl @InTuple [template = constants.%InTuple] {
  146. // CHECK:STDOUT: %c.patt: %tuple.type.2a3 = binding_pattern c
  147. // CHECK:STDOUT: %c.param_patt: %tuple.type.2a3 = value_param_pattern %c.patt, runtime_param0
  148. // CHECK:STDOUT: %return.patt: %tuple.type.2a3 = return_slot_pattern
  149. // CHECK:STDOUT: %return.param_patt: %tuple.type.2a3 = out_param_pattern %return.patt, runtime_param1
  150. // CHECK:STDOUT: } {
  151. // CHECK:STDOUT: %AdaptCopyable.ref.loc15_41: type = name_ref AdaptCopyable, file.%AdaptCopyable.decl [template = constants.%AdaptCopyable]
  152. // CHECK:STDOUT: %int_32.loc15_56: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  153. // CHECK:STDOUT: %u32.loc15_56: type = class_type @UInt, @UInt(constants.%int_32) [template = constants.%u32]
  154. // CHECK:STDOUT: %.loc15_59.1: %tuple.type.24b = tuple_literal (%AdaptCopyable.ref.loc15_41, %u32.loc15_56)
  155. // CHECK:STDOUT: %.loc15_59.2: type = converted %.loc15_59.1, constants.%tuple.type.2a3 [template = constants.%tuple.type.2a3]
  156. // CHECK:STDOUT: %c.param: %tuple.type.2a3 = value_param runtime_param0
  157. // CHECK:STDOUT: %.loc15_34.1: type = splice_block %.loc15_34.3 [template = constants.%tuple.type.2a3] {
  158. // CHECK:STDOUT: %AdaptCopyable.ref.loc15_16: type = name_ref AdaptCopyable, file.%AdaptCopyable.decl [template = constants.%AdaptCopyable]
  159. // CHECK:STDOUT: %int_32.loc15_31: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  160. // CHECK:STDOUT: %u32.loc15_31: type = class_type @UInt, @UInt(constants.%int_32) [template = constants.%u32]
  161. // CHECK:STDOUT: %.loc15_34.2: %tuple.type.24b = tuple_literal (%AdaptCopyable.ref.loc15_16, %u32.loc15_31)
  162. // CHECK:STDOUT: %.loc15_34.3: type = converted %.loc15_34.2, constants.%tuple.type.2a3 [template = constants.%tuple.type.2a3]
  163. // CHECK:STDOUT: }
  164. // CHECK:STDOUT: %c: %tuple.type.2a3 = bind_name c, %c.param
  165. // CHECK:STDOUT: %return.param: ref %tuple.type.2a3 = out_param runtime_param1
  166. // CHECK:STDOUT: %return: ref %tuple.type.2a3 = return_slot %return.param
  167. // CHECK:STDOUT: }
  168. // CHECK:STDOUT: }
  169. // CHECK:STDOUT:
  170. // CHECK:STDOUT: class @AdaptCopyable {
  171. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  172. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  173. // CHECK:STDOUT: adapt_decl %i32 [template]
  174. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %i32.builtin [template = constants.%complete_type.f8a]
  175. // CHECK:STDOUT: complete_type_witness = %complete_type
  176. // CHECK:STDOUT:
  177. // CHECK:STDOUT: !members:
  178. // CHECK:STDOUT: .Self = constants.%AdaptCopyable
  179. // CHECK:STDOUT: }
  180. // CHECK:STDOUT:
  181. // CHECK:STDOUT: fn @F(%c.param_patt: %AdaptCopyable) -> %AdaptCopyable {
  182. // CHECK:STDOUT: !entry:
  183. // CHECK:STDOUT: name_binding_decl {
  184. // CHECK:STDOUT: %d.patt: %AdaptCopyable = binding_pattern d
  185. // CHECK:STDOUT: %.loc11: %AdaptCopyable = var_pattern %d.patt
  186. // CHECK:STDOUT: }
  187. // CHECK:STDOUT: %d.var: ref %AdaptCopyable = var d
  188. // CHECK:STDOUT: %c.ref: %AdaptCopyable = name_ref c, %c
  189. // CHECK:STDOUT: assign %d.var, %c.ref
  190. // CHECK:STDOUT: %AdaptCopyable.ref.loc11: type = name_ref AdaptCopyable, file.%AdaptCopyable.decl [template = constants.%AdaptCopyable]
  191. // CHECK:STDOUT: %d: ref %AdaptCopyable = bind_name d, %d.var
  192. // CHECK:STDOUT: %d.ref: ref %AdaptCopyable = name_ref d, %d
  193. // CHECK:STDOUT: %.loc12: %AdaptCopyable = bind_value %d.ref
  194. // CHECK:STDOUT: return %.loc12
  195. // CHECK:STDOUT: }
  196. // CHECK:STDOUT:
  197. // CHECK:STDOUT: fn @InTuple(%c.param_patt: %tuple.type.2a3) -> %return.param_patt: %tuple.type.2a3 {
  198. // CHECK:STDOUT: !entry:
  199. // CHECK:STDOUT: name_binding_decl {
  200. // CHECK:STDOUT: %d.patt: %tuple.type.2a3 = binding_pattern d
  201. // CHECK:STDOUT: %.loc16_3.1: %tuple.type.2a3 = var_pattern %d.patt
  202. // CHECK:STDOUT: }
  203. // CHECK:STDOUT: %d.var: ref %tuple.type.2a3 = var d
  204. // CHECK:STDOUT: %c.ref: %tuple.type.2a3 = name_ref c, %c
  205. // CHECK:STDOUT: %tuple.elem0.loc16_33.1: %AdaptCopyable = tuple_access %c.ref, element0
  206. // CHECK:STDOUT: %tuple.elem0.loc16_33.2: ref %AdaptCopyable = tuple_access %d.var, element0
  207. // CHECK:STDOUT: %.loc16_33.1: init %AdaptCopyable = initialize_from %tuple.elem0.loc16_33.1 to %tuple.elem0.loc16_33.2
  208. // CHECK:STDOUT: %tuple.elem1.loc16_33.1: %u32 = tuple_access %c.ref, element1
  209. // CHECK:STDOUT: %tuple.elem1.loc16_33.2: ref %u32 = tuple_access %d.var, element1
  210. // CHECK:STDOUT: %.loc16_33.2: init %u32 = initialize_from %tuple.elem1.loc16_33.1 to %tuple.elem1.loc16_33.2
  211. // CHECK:STDOUT: %.loc16_33.3: init %tuple.type.2a3 = tuple_init (%.loc16_33.1, %.loc16_33.2) to %d.var
  212. // CHECK:STDOUT: %.loc16_3.2: init %tuple.type.2a3 = converted %c.ref, %.loc16_33.3
  213. // CHECK:STDOUT: assign %d.var, %.loc16_3.2
  214. // CHECK:STDOUT: %.loc16_29.1: type = splice_block %.loc16_29.3 [template = constants.%tuple.type.2a3] {
  215. // CHECK:STDOUT: %AdaptCopyable.ref.loc16: type = name_ref AdaptCopyable, file.%AdaptCopyable.decl [template = constants.%AdaptCopyable]
  216. // CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  217. // CHECK:STDOUT: %u32.loc16: type = class_type @UInt, @UInt(constants.%int_32) [template = constants.%u32]
  218. // CHECK:STDOUT: %.loc16_29.2: %tuple.type.24b = tuple_literal (%AdaptCopyable.ref.loc16, %u32.loc16)
  219. // CHECK:STDOUT: %.loc16_29.3: type = converted %.loc16_29.2, constants.%tuple.type.2a3 [template = constants.%tuple.type.2a3]
  220. // CHECK:STDOUT: }
  221. // CHECK:STDOUT: %d: ref %tuple.type.2a3 = bind_name d, %d.var
  222. // CHECK:STDOUT: %d.ref: ref %tuple.type.2a3 = name_ref d, %d
  223. // CHECK:STDOUT: %tuple.elem0.loc17_10.1: ref %AdaptCopyable = tuple_access %d.ref, element0
  224. // CHECK:STDOUT: %.loc17_10.1: %AdaptCopyable = bind_value %tuple.elem0.loc17_10.1
  225. // CHECK:STDOUT: %tuple.elem0.loc17_10.2: ref %AdaptCopyable = tuple_access %return, element0
  226. // CHECK:STDOUT: %.loc17_10.2: init %AdaptCopyable = initialize_from %.loc17_10.1 to %tuple.elem0.loc17_10.2
  227. // CHECK:STDOUT: %tuple.elem1.loc17_10.1: ref %u32 = tuple_access %d.ref, element1
  228. // CHECK:STDOUT: %.loc17_10.3: %u32 = bind_value %tuple.elem1.loc17_10.1
  229. // CHECK:STDOUT: %tuple.elem1.loc17_10.2: ref %u32 = tuple_access %return, element1
  230. // CHECK:STDOUT: %.loc17_10.4: init %u32 = initialize_from %.loc17_10.3 to %tuple.elem1.loc17_10.2
  231. // CHECK:STDOUT: %.loc17_10.5: init %tuple.type.2a3 = tuple_init (%.loc17_10.2, %.loc17_10.4) to %return
  232. // CHECK:STDOUT: %.loc17_11: init %tuple.type.2a3 = converted %d.ref, %.loc17_10.5
  233. // CHECK:STDOUT: return %.loc17_11 to %return
  234. // CHECK:STDOUT: }
  235. // CHECK:STDOUT:
  236. // CHECK:STDOUT: --- adapt_copyable_tuple.carbon
  237. // CHECK:STDOUT:
  238. // CHECK:STDOUT: constants {
  239. // CHECK:STDOUT: %AdaptTuple: type = class_type @AdaptTuple [template]
  240. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  241. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  242. // CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template]
  243. // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template]
  244. // CHECK:STDOUT: %complete_type.65d: <witness> = complete_type_witness %tuple.type.d07 [template]
  245. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  246. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  247. // CHECK:STDOUT: %u32: type = class_type @UInt, @UInt(%int_32) [template]
  248. // CHECK:STDOUT: %tuple.type.f69: type = tuple_type (%AdaptTuple, %u32) [template]
  249. // CHECK:STDOUT: %InTuple.type: type = fn_type @InTuple [template]
  250. // CHECK:STDOUT: %InTuple: %InTuple.type = struct_value () [template]
  251. // CHECK:STDOUT: }
  252. // CHECK:STDOUT:
  253. // CHECK:STDOUT: imports {
  254. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  255. // CHECK:STDOUT: .Int = %Core.Int
  256. // CHECK:STDOUT: .UInt = %Core.UInt
  257. // CHECK:STDOUT: import Core//prelude
  258. // CHECK:STDOUT: import Core//prelude/...
  259. // CHECK:STDOUT: }
  260. // CHECK:STDOUT: }
  261. // CHECK:STDOUT:
  262. // CHECK:STDOUT: file {
  263. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  264. // CHECK:STDOUT: .Core = imports.%Core
  265. // CHECK:STDOUT: .AdaptTuple = %AdaptTuple.decl
  266. // CHECK:STDOUT: .F = %F.decl
  267. // CHECK:STDOUT: .InTuple = %InTuple.decl
  268. // CHECK:STDOUT: }
  269. // CHECK:STDOUT: %Core.import = import Core
  270. // CHECK:STDOUT: %AdaptTuple.decl: type = class_decl @AdaptTuple [template = constants.%AdaptTuple] {} {}
  271. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  272. // CHECK:STDOUT: %c.patt: %AdaptTuple = binding_pattern c
  273. // CHECK:STDOUT: %c.param_patt: %AdaptTuple = value_param_pattern %c.patt, runtime_param0
  274. // CHECK:STDOUT: %return.patt: %AdaptTuple = return_slot_pattern
  275. // CHECK:STDOUT: %return.param_patt: %AdaptTuple = out_param_pattern %return.patt, runtime_param1
  276. // CHECK:STDOUT: } {
  277. // CHECK:STDOUT: %AdaptTuple.ref.loc8_24: type = name_ref AdaptTuple, file.%AdaptTuple.decl [template = constants.%AdaptTuple]
  278. // CHECK:STDOUT: %c.param: %AdaptTuple = value_param runtime_param0
  279. // CHECK:STDOUT: %AdaptTuple.ref.loc8_9: type = name_ref AdaptTuple, file.%AdaptTuple.decl [template = constants.%AdaptTuple]
  280. // CHECK:STDOUT: %c: %AdaptTuple = bind_name c, %c.param
  281. // CHECK:STDOUT: %return.param: ref %AdaptTuple = out_param runtime_param1
  282. // CHECK:STDOUT: %return: ref %AdaptTuple = return_slot %return.param
  283. // CHECK:STDOUT: }
  284. // CHECK:STDOUT: %InTuple.decl: %InTuple.type = fn_decl @InTuple [template = constants.%InTuple] {
  285. // CHECK:STDOUT: %c.patt: %tuple.type.f69 = binding_pattern c
  286. // CHECK:STDOUT: %c.param_patt: %tuple.type.f69 = value_param_pattern %c.patt, runtime_param0
  287. // CHECK:STDOUT: %return.patt: %tuple.type.f69 = return_slot_pattern
  288. // CHECK:STDOUT: %return.param_patt: %tuple.type.f69 = out_param_pattern %return.patt, runtime_param1
  289. // CHECK:STDOUT: } {
  290. // CHECK:STDOUT: %AdaptTuple.ref.loc13_38: type = name_ref AdaptTuple, file.%AdaptTuple.decl [template = constants.%AdaptTuple]
  291. // CHECK:STDOUT: %int_32.loc13_50: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  292. // CHECK:STDOUT: %u32.loc13_50: type = class_type @UInt, @UInt(constants.%int_32) [template = constants.%u32]
  293. // CHECK:STDOUT: %.loc13_53.1: %tuple.type.24b = tuple_literal (%AdaptTuple.ref.loc13_38, %u32.loc13_50)
  294. // CHECK:STDOUT: %.loc13_53.2: type = converted %.loc13_53.1, constants.%tuple.type.f69 [template = constants.%tuple.type.f69]
  295. // CHECK:STDOUT: %c.param: %tuple.type.f69 = value_param runtime_param0
  296. // CHECK:STDOUT: %.loc13_31.1: type = splice_block %.loc13_31.3 [template = constants.%tuple.type.f69] {
  297. // CHECK:STDOUT: %AdaptTuple.ref.loc13_16: type = name_ref AdaptTuple, file.%AdaptTuple.decl [template = constants.%AdaptTuple]
  298. // CHECK:STDOUT: %int_32.loc13_28: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  299. // CHECK:STDOUT: %u32.loc13_28: type = class_type @UInt, @UInt(constants.%int_32) [template = constants.%u32]
  300. // CHECK:STDOUT: %.loc13_31.2: %tuple.type.24b = tuple_literal (%AdaptTuple.ref.loc13_16, %u32.loc13_28)
  301. // CHECK:STDOUT: %.loc13_31.3: type = converted %.loc13_31.2, constants.%tuple.type.f69 [template = constants.%tuple.type.f69]
  302. // CHECK:STDOUT: }
  303. // CHECK:STDOUT: %c: %tuple.type.f69 = bind_name c, %c.param
  304. // CHECK:STDOUT: %return.param: ref %tuple.type.f69 = out_param runtime_param1
  305. // CHECK:STDOUT: %return: ref %tuple.type.f69 = return_slot %return.param
  306. // CHECK:STDOUT: }
  307. // CHECK:STDOUT: }
  308. // CHECK:STDOUT:
  309. // CHECK:STDOUT: class @AdaptTuple {
  310. // CHECK:STDOUT: %int_32.loc5_10: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  311. // CHECK:STDOUT: %i32.loc5_10: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  312. // CHECK:STDOUT: %int_32.loc5_15: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  313. // CHECK:STDOUT: %i32.loc5_15: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  314. // CHECK:STDOUT: %.loc5_18: %tuple.type.24b = tuple_literal (%i32.loc5_10, %i32.loc5_15)
  315. // CHECK:STDOUT: %.loc5_19: type = converted %.loc5_18, constants.%tuple.type.d07 [template = constants.%tuple.type.d07]
  316. // CHECK:STDOUT: adapt_decl %.loc5_19 [template]
  317. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %tuple.type.d07 [template = constants.%complete_type.65d]
  318. // CHECK:STDOUT: complete_type_witness = %complete_type
  319. // CHECK:STDOUT:
  320. // CHECK:STDOUT: !members:
  321. // CHECK:STDOUT: .Self = constants.%AdaptTuple
  322. // CHECK:STDOUT: }
  323. // CHECK:STDOUT:
  324. // CHECK:STDOUT: fn @F(%c.param_patt: %AdaptTuple) -> %return.param_patt: %AdaptTuple {
  325. // CHECK:STDOUT: !entry:
  326. // CHECK:STDOUT: name_binding_decl {
  327. // CHECK:STDOUT: %d.patt: %AdaptTuple = binding_pattern d
  328. // CHECK:STDOUT: %.loc9_3.1: %AdaptTuple = var_pattern %d.patt
  329. // CHECK:STDOUT: }
  330. // CHECK:STDOUT: %d.var: ref %AdaptTuple = var d
  331. // CHECK:STDOUT: %c.ref: %AdaptTuple = name_ref c, %c
  332. // CHECK:STDOUT: %.loc9_3.2: %tuple.type.d07 = as_compatible %c.ref
  333. // CHECK:STDOUT: %tuple.elem0.loc9_3.1: %i32 = tuple_access %.loc9_3.2, element0
  334. // CHECK:STDOUT: %.loc9_3.3: ref %tuple.type.d07 = as_compatible %d.var
  335. // CHECK:STDOUT: %tuple.elem0.loc9_3.2: ref %i32 = tuple_access %.loc9_3.3, element0
  336. // CHECK:STDOUT: %.loc9_3.4: init %i32 = initialize_from %tuple.elem0.loc9_3.1 to %tuple.elem0.loc9_3.2
  337. // CHECK:STDOUT: %tuple.elem1.loc9_3.1: %i32 = tuple_access %.loc9_3.2, element1
  338. // CHECK:STDOUT: %tuple.elem1.loc9_3.2: ref %i32 = tuple_access %.loc9_3.3, element1
  339. // CHECK:STDOUT: %.loc9_3.5: init %i32 = initialize_from %tuple.elem1.loc9_3.1 to %tuple.elem1.loc9_3.2
  340. // CHECK:STDOUT: %.loc9_3.6: init %tuple.type.d07 = tuple_init (%.loc9_3.4, %.loc9_3.5) to %.loc9_3.3
  341. // CHECK:STDOUT: %.loc9_3.7: init %AdaptTuple = as_compatible %.loc9_3.6
  342. // CHECK:STDOUT: %.loc9_3.8: init %AdaptTuple = converted %c.ref, %.loc9_3.7
  343. // CHECK:STDOUT: assign %d.var, %.loc9_3.8
  344. // CHECK:STDOUT: %AdaptTuple.ref.loc9: type = name_ref AdaptTuple, file.%AdaptTuple.decl [template = constants.%AdaptTuple]
  345. // CHECK:STDOUT: %d: ref %AdaptTuple = bind_name d, %d.var
  346. // CHECK:STDOUT: %d.ref: ref %AdaptTuple = name_ref d, %d
  347. // CHECK:STDOUT: %.loc10_11.1: ref %tuple.type.d07 = as_compatible %d.ref
  348. // CHECK:STDOUT: %tuple.elem0.loc10_11.1: ref %i32 = tuple_access %.loc10_11.1, element0
  349. // CHECK:STDOUT: %.loc10_11.2: %i32 = bind_value %tuple.elem0.loc10_11.1
  350. // CHECK:STDOUT: %.loc10_11.3: ref %tuple.type.d07 = as_compatible %return
  351. // CHECK:STDOUT: %tuple.elem0.loc10_11.2: ref %i32 = tuple_access %.loc10_11.3, element0
  352. // CHECK:STDOUT: %.loc10_11.4: init %i32 = initialize_from %.loc10_11.2 to %tuple.elem0.loc10_11.2
  353. // CHECK:STDOUT: %tuple.elem1.loc10_11.1: ref %i32 = tuple_access %.loc10_11.1, element1
  354. // CHECK:STDOUT: %.loc10_11.5: %i32 = bind_value %tuple.elem1.loc10_11.1
  355. // CHECK:STDOUT: %tuple.elem1.loc10_11.2: ref %i32 = tuple_access %.loc10_11.3, element1
  356. // CHECK:STDOUT: %.loc10_11.6: init %i32 = initialize_from %.loc10_11.5 to %tuple.elem1.loc10_11.2
  357. // CHECK:STDOUT: %.loc10_11.7: init %tuple.type.d07 = tuple_init (%.loc10_11.4, %.loc10_11.6) to %.loc10_11.3
  358. // CHECK:STDOUT: %.loc10_11.8: init %AdaptTuple = as_compatible %.loc10_11.7
  359. // CHECK:STDOUT: %.loc10_11.9: init %AdaptTuple = converted %d.ref, %.loc10_11.8
  360. // CHECK:STDOUT: return %.loc10_11.9 to %return
  361. // CHECK:STDOUT: }
  362. // CHECK:STDOUT:
  363. // CHECK:STDOUT: fn @InTuple(%c.param_patt: %tuple.type.f69) -> %return.param_patt: %tuple.type.f69 {
  364. // CHECK:STDOUT: !entry:
  365. // CHECK:STDOUT: name_binding_decl {
  366. // CHECK:STDOUT: %d.patt: %tuple.type.f69 = binding_pattern d
  367. // CHECK:STDOUT: %.loc14_3.1: %tuple.type.f69 = var_pattern %d.patt
  368. // CHECK:STDOUT: }
  369. // CHECK:STDOUT: %d.var: ref %tuple.type.f69 = var d
  370. // CHECK:STDOUT: %c.ref: %tuple.type.f69 = name_ref c, %c
  371. // CHECK:STDOUT: %tuple.elem0.loc14_30.1: %AdaptTuple = tuple_access %c.ref, element0
  372. // CHECK:STDOUT: %.loc14_30.1: %tuple.type.d07 = as_compatible %tuple.elem0.loc14_30.1
  373. // CHECK:STDOUT: %tuple.elem0.loc14_30.2: %i32 = tuple_access %.loc14_30.1, element0
  374. // CHECK:STDOUT: %tuple.elem0.loc14_30.3: ref %AdaptTuple = tuple_access %d.var, element0
  375. // CHECK:STDOUT: %.loc14_30.2: ref %tuple.type.d07 = as_compatible %tuple.elem0.loc14_30.3
  376. // CHECK:STDOUT: %tuple.elem0.loc14_30.4: ref %i32 = tuple_access %.loc14_30.2, element0
  377. // CHECK:STDOUT: %.loc14_30.3: init %i32 = initialize_from %tuple.elem0.loc14_30.2 to %tuple.elem0.loc14_30.4
  378. // CHECK:STDOUT: %tuple.elem1.loc14_30.1: %i32 = tuple_access %.loc14_30.1, element1
  379. // CHECK:STDOUT: %tuple.elem1.loc14_30.2: ref %i32 = tuple_access %.loc14_30.2, element1
  380. // CHECK:STDOUT: %.loc14_30.4: init %i32 = initialize_from %tuple.elem1.loc14_30.1 to %tuple.elem1.loc14_30.2
  381. // CHECK:STDOUT: %.loc14_30.5: init %tuple.type.d07 = tuple_init (%.loc14_30.3, %.loc14_30.4) to %.loc14_30.2
  382. // CHECK:STDOUT: %.loc14_30.6: init %AdaptTuple = as_compatible %.loc14_30.5
  383. // CHECK:STDOUT: %.loc14_30.7: init %AdaptTuple = converted %tuple.elem0.loc14_30.1, %.loc14_30.6
  384. // CHECK:STDOUT: %tuple.elem1.loc14_30.3: %u32 = tuple_access %c.ref, element1
  385. // CHECK:STDOUT: %tuple.elem1.loc14_30.4: ref %u32 = tuple_access %d.var, element1
  386. // CHECK:STDOUT: %.loc14_30.8: init %u32 = initialize_from %tuple.elem1.loc14_30.3 to %tuple.elem1.loc14_30.4
  387. // CHECK:STDOUT: %.loc14_30.9: init %tuple.type.f69 = tuple_init (%.loc14_30.7, %.loc14_30.8) to %d.var
  388. // CHECK:STDOUT: %.loc14_3.2: init %tuple.type.f69 = converted %c.ref, %.loc14_30.9
  389. // CHECK:STDOUT: assign %d.var, %.loc14_3.2
  390. // CHECK:STDOUT: %.loc14_26.1: type = splice_block %.loc14_26.3 [template = constants.%tuple.type.f69] {
  391. // CHECK:STDOUT: %AdaptTuple.ref.loc14: type = name_ref AdaptTuple, file.%AdaptTuple.decl [template = constants.%AdaptTuple]
  392. // CHECK:STDOUT: %int_32.loc14: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  393. // CHECK:STDOUT: %u32.loc14: type = class_type @UInt, @UInt(constants.%int_32) [template = constants.%u32]
  394. // CHECK:STDOUT: %.loc14_26.2: %tuple.type.24b = tuple_literal (%AdaptTuple.ref.loc14, %u32.loc14)
  395. // CHECK:STDOUT: %.loc14_26.3: type = converted %.loc14_26.2, constants.%tuple.type.f69 [template = constants.%tuple.type.f69]
  396. // CHECK:STDOUT: }
  397. // CHECK:STDOUT: %d: ref %tuple.type.f69 = bind_name d, %d.var
  398. // CHECK:STDOUT: %d.ref: ref %tuple.type.f69 = name_ref d, %d
  399. // CHECK:STDOUT: %tuple.elem0.loc15_10.1: ref %AdaptTuple = tuple_access %d.ref, element0
  400. // CHECK:STDOUT: %.loc15_10.1: ref %tuple.type.d07 = as_compatible %tuple.elem0.loc15_10.1
  401. // CHECK:STDOUT: %tuple.elem0.loc15_10.2: ref %i32 = tuple_access %.loc15_10.1, element0
  402. // CHECK:STDOUT: %.loc15_10.2: %i32 = bind_value %tuple.elem0.loc15_10.2
  403. // CHECK:STDOUT: %tuple.elem0.loc15_10.3: ref %AdaptTuple = tuple_access %return, element0
  404. // CHECK:STDOUT: %.loc15_10.3: ref %tuple.type.d07 = as_compatible %tuple.elem0.loc15_10.3
  405. // CHECK:STDOUT: %tuple.elem0.loc15_10.4: ref %i32 = tuple_access %.loc15_10.3, element0
  406. // CHECK:STDOUT: %.loc15_10.4: init %i32 = initialize_from %.loc15_10.2 to %tuple.elem0.loc15_10.4
  407. // CHECK:STDOUT: %tuple.elem1.loc15_10.1: ref %i32 = tuple_access %.loc15_10.1, element1
  408. // CHECK:STDOUT: %.loc15_10.5: %i32 = bind_value %tuple.elem1.loc15_10.1
  409. // CHECK:STDOUT: %tuple.elem1.loc15_10.2: ref %i32 = tuple_access %.loc15_10.3, element1
  410. // CHECK:STDOUT: %.loc15_10.6: init %i32 = initialize_from %.loc15_10.5 to %tuple.elem1.loc15_10.2
  411. // CHECK:STDOUT: %.loc15_10.7: init %tuple.type.d07 = tuple_init (%.loc15_10.4, %.loc15_10.6) to %.loc15_10.3
  412. // CHECK:STDOUT: %.loc15_10.8: init %AdaptTuple = as_compatible %.loc15_10.7
  413. // CHECK:STDOUT: %.loc15_10.9: init %AdaptTuple = converted %tuple.elem0.loc15_10.1, %.loc15_10.8
  414. // CHECK:STDOUT: %tuple.elem1.loc15_10.3: ref %u32 = tuple_access %d.ref, element1
  415. // CHECK:STDOUT: %.loc15_10.10: %u32 = bind_value %tuple.elem1.loc15_10.3
  416. // CHECK:STDOUT: %tuple.elem1.loc15_10.4: ref %u32 = tuple_access %return, element1
  417. // CHECK:STDOUT: %.loc15_10.11: init %u32 = initialize_from %.loc15_10.10 to %tuple.elem1.loc15_10.4
  418. // CHECK:STDOUT: %.loc15_10.12: init %tuple.type.f69 = tuple_init (%.loc15_10.9, %.loc15_10.11) to %return
  419. // CHECK:STDOUT: %.loc15_11: init %tuple.type.f69 = converted %d.ref, %.loc15_10.12
  420. // CHECK:STDOUT: return %.loc15_11 to %return
  421. // CHECK:STDOUT: }
  422. // CHECK:STDOUT:
  423. // CHECK:STDOUT: --- fail_adapt_not_copyable.carbon
  424. // CHECK:STDOUT:
  425. // CHECK:STDOUT: constants {
  426. // CHECK:STDOUT: %Noncopyable: type = class_type @Noncopyable [template]
  427. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  428. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  429. // CHECK:STDOUT: %AdaptNoncopyable: type = class_type @AdaptNoncopyable [template]
  430. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  431. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  432. // CHECK:STDOUT: }
  433. // CHECK:STDOUT:
  434. // CHECK:STDOUT: imports {
  435. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  436. // CHECK:STDOUT: import Core//prelude
  437. // CHECK:STDOUT: import Core//prelude/...
  438. // CHECK:STDOUT: }
  439. // CHECK:STDOUT: }
  440. // CHECK:STDOUT:
  441. // CHECK:STDOUT: file {
  442. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  443. // CHECK:STDOUT: .Core = imports.%Core
  444. // CHECK:STDOUT: .Noncopyable = %Noncopyable.decl
  445. // CHECK:STDOUT: .AdaptNoncopyable = %AdaptNoncopyable.decl
  446. // CHECK:STDOUT: .G = %G.decl
  447. // CHECK:STDOUT: }
  448. // CHECK:STDOUT: %Core.import = import Core
  449. // CHECK:STDOUT: %Noncopyable.decl: type = class_decl @Noncopyable [template = constants.%Noncopyable] {} {}
  450. // CHECK:STDOUT: %AdaptNoncopyable.decl: type = class_decl @AdaptNoncopyable [template = constants.%AdaptNoncopyable] {} {}
  451. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  452. // CHECK:STDOUT: %a.patt: %AdaptNoncopyable = binding_pattern a
  453. // CHECK:STDOUT: %a.param_patt: %AdaptNoncopyable = value_param_pattern %a.patt, runtime_param0
  454. // CHECK:STDOUT: %return.patt: %AdaptNoncopyable = return_slot_pattern
  455. // CHECK:STDOUT: %return.param_patt: %AdaptNoncopyable = out_param_pattern %return.patt, runtime_param1
  456. // CHECK:STDOUT: } {
  457. // CHECK:STDOUT: %AdaptNoncopyable.ref.loc12_30: type = name_ref AdaptNoncopyable, file.%AdaptNoncopyable.decl [template = constants.%AdaptNoncopyable]
  458. // CHECK:STDOUT: %a.param: %AdaptNoncopyable = value_param runtime_param0
  459. // CHECK:STDOUT: %AdaptNoncopyable.ref.loc12_9: type = name_ref AdaptNoncopyable, file.%AdaptNoncopyable.decl [template = constants.%AdaptNoncopyable]
  460. // CHECK:STDOUT: %a: %AdaptNoncopyable = bind_name a, %a.param
  461. // CHECK:STDOUT: %return.param: ref %AdaptNoncopyable = out_param runtime_param1
  462. // CHECK:STDOUT: %return: ref %AdaptNoncopyable = return_slot %return.param
  463. // CHECK:STDOUT: }
  464. // CHECK:STDOUT: }
  465. // CHECK:STDOUT:
  466. // CHECK:STDOUT: class @Noncopyable {
  467. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  468. // CHECK:STDOUT: complete_type_witness = %complete_type
  469. // CHECK:STDOUT:
  470. // CHECK:STDOUT: !members:
  471. // CHECK:STDOUT: .Self = constants.%Noncopyable
  472. // CHECK:STDOUT: }
  473. // CHECK:STDOUT:
  474. // CHECK:STDOUT: class @AdaptNoncopyable {
  475. // CHECK:STDOUT: %Noncopyable.ref: type = name_ref Noncopyable, file.%Noncopyable.decl [template = constants.%Noncopyable]
  476. // CHECK:STDOUT: adapt_decl %Noncopyable.ref [template]
  477. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  478. // CHECK:STDOUT: complete_type_witness = %complete_type
  479. // CHECK:STDOUT:
  480. // CHECK:STDOUT: !members:
  481. // CHECK:STDOUT: .Self = constants.%AdaptNoncopyable
  482. // CHECK:STDOUT: }
  483. // CHECK:STDOUT:
  484. // CHECK:STDOUT: fn @G(%a.param_patt: %AdaptNoncopyable) -> %return.param_patt: %AdaptNoncopyable {
  485. // CHECK:STDOUT: !entry:
  486. // CHECK:STDOUT: name_binding_decl {
  487. // CHECK:STDOUT: %b.patt: %AdaptNoncopyable = binding_pattern b
  488. // CHECK:STDOUT: %.loc17: %AdaptNoncopyable = var_pattern %b.patt
  489. // CHECK:STDOUT: }
  490. // CHECK:STDOUT: %b.var: ref %AdaptNoncopyable = var b
  491. // CHECK:STDOUT: %a.ref: %AdaptNoncopyable = name_ref a, %a
  492. // CHECK:STDOUT: assign %b.var, <error>
  493. // CHECK:STDOUT: %AdaptNoncopyable.ref.loc17: type = name_ref AdaptNoncopyable, file.%AdaptNoncopyable.decl [template = constants.%AdaptNoncopyable]
  494. // CHECK:STDOUT: %b: ref %AdaptNoncopyable = bind_name b, %b.var
  495. // CHECK:STDOUT: %b.ref: ref %AdaptNoncopyable = name_ref b, %b
  496. // CHECK:STDOUT: %.loc22: %AdaptNoncopyable = bind_value %b.ref
  497. // CHECK:STDOUT: return <error> to %return
  498. // CHECK:STDOUT: }
  499. // CHECK:STDOUT:
  500. // CHECK:STDOUT: --- fail_adapt_not_copyable_indirect.carbon
  501. // CHECK:STDOUT:
  502. // CHECK:STDOUT: constants {
  503. // CHECK:STDOUT: %Noncopyable: type = class_type @Noncopyable [template]
  504. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  505. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [template]
  506. // CHECK:STDOUT: %AdaptNoncopyableIndirect: type = class_type @AdaptNoncopyableIndirect [template]
  507. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  508. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  509. // CHECK:STDOUT: %tuple.type.ff9: type = tuple_type (type, type, type) [template]
  510. // CHECK:STDOUT: %tuple.type.c9a: type = tuple_type (%i32, %Noncopyable, %i32) [template]
  511. // CHECK:STDOUT: %complete_type.201: <witness> = complete_type_witness %tuple.type.c9a [template]
  512. // CHECK:STDOUT: %H.type: type = fn_type @H [template]
  513. // CHECK:STDOUT: %H: %H.type = struct_value () [template]
  514. // CHECK:STDOUT: }
  515. // CHECK:STDOUT:
  516. // CHECK:STDOUT: imports {
  517. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  518. // CHECK:STDOUT: .Int = %Core.Int
  519. // CHECK:STDOUT: import Core//prelude
  520. // CHECK:STDOUT: import Core//prelude/...
  521. // CHECK:STDOUT: }
  522. // CHECK:STDOUT: }
  523. // CHECK:STDOUT:
  524. // CHECK:STDOUT: file {
  525. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  526. // CHECK:STDOUT: .Core = imports.%Core
  527. // CHECK:STDOUT: .Noncopyable = %Noncopyable.decl
  528. // CHECK:STDOUT: .AdaptNoncopyableIndirect = %AdaptNoncopyableIndirect.decl
  529. // CHECK:STDOUT: .H = %H.decl
  530. // CHECK:STDOUT: }
  531. // CHECK:STDOUT: %Core.import = import Core
  532. // CHECK:STDOUT: %Noncopyable.decl: type = class_decl @Noncopyable [template = constants.%Noncopyable] {} {}
  533. // CHECK:STDOUT: %AdaptNoncopyableIndirect.decl: type = class_decl @AdaptNoncopyableIndirect [template = constants.%AdaptNoncopyableIndirect] {} {}
  534. // CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [template = constants.%H] {
  535. // CHECK:STDOUT: %a.patt: %AdaptNoncopyableIndirect = binding_pattern a
  536. // CHECK:STDOUT: %a.param_patt: %AdaptNoncopyableIndirect = value_param_pattern %a.patt, runtime_param0
  537. // CHECK:STDOUT: %return.patt: %AdaptNoncopyableIndirect = return_slot_pattern
  538. // CHECK:STDOUT: %return.param_patt: %AdaptNoncopyableIndirect = out_param_pattern %return.patt, runtime_param1
  539. // CHECK:STDOUT: } {
  540. // CHECK:STDOUT: %AdaptNoncopyableIndirect.ref.loc12_38: type = name_ref AdaptNoncopyableIndirect, file.%AdaptNoncopyableIndirect.decl [template = constants.%AdaptNoncopyableIndirect]
  541. // CHECK:STDOUT: %a.param: %AdaptNoncopyableIndirect = value_param runtime_param0
  542. // CHECK:STDOUT: %AdaptNoncopyableIndirect.ref.loc12_9: type = name_ref AdaptNoncopyableIndirect, file.%AdaptNoncopyableIndirect.decl [template = constants.%AdaptNoncopyableIndirect]
  543. // CHECK:STDOUT: %a: %AdaptNoncopyableIndirect = bind_name a, %a.param
  544. // CHECK:STDOUT: %return.param: ref %AdaptNoncopyableIndirect = out_param runtime_param1
  545. // CHECK:STDOUT: %return: ref %AdaptNoncopyableIndirect = return_slot %return.param
  546. // CHECK:STDOUT: }
  547. // CHECK:STDOUT: }
  548. // CHECK:STDOUT:
  549. // CHECK:STDOUT: class @Noncopyable {
  550. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
  551. // CHECK:STDOUT: complete_type_witness = %complete_type
  552. // CHECK:STDOUT:
  553. // CHECK:STDOUT: !members:
  554. // CHECK:STDOUT: .Self = constants.%Noncopyable
  555. // CHECK:STDOUT: }
  556. // CHECK:STDOUT:
  557. // CHECK:STDOUT: class @AdaptNoncopyableIndirect {
  558. // CHECK:STDOUT: %int_32.loc9_10: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  559. // CHECK:STDOUT: %i32.loc9_10: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  560. // CHECK:STDOUT: %Noncopyable.ref: type = name_ref Noncopyable, file.%Noncopyable.decl [template = constants.%Noncopyable]
  561. // CHECK:STDOUT: %int_32.loc9_28: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  562. // CHECK:STDOUT: %i32.loc9_28: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  563. // CHECK:STDOUT: %.loc9_31: %tuple.type.ff9 = tuple_literal (%i32.loc9_10, %Noncopyable.ref, %i32.loc9_28)
  564. // CHECK:STDOUT: %.loc9_32: type = converted %.loc9_31, constants.%tuple.type.c9a [template = constants.%tuple.type.c9a]
  565. // CHECK:STDOUT: adapt_decl %.loc9_32 [template]
  566. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %tuple.type.c9a [template = constants.%complete_type.201]
  567. // CHECK:STDOUT: complete_type_witness = %complete_type
  568. // CHECK:STDOUT:
  569. // CHECK:STDOUT: !members:
  570. // CHECK:STDOUT: .Self = constants.%AdaptNoncopyableIndirect
  571. // CHECK:STDOUT: }
  572. // CHECK:STDOUT:
  573. // CHECK:STDOUT: fn @H(%a.param_patt: %AdaptNoncopyableIndirect) -> %return.param_patt: %AdaptNoncopyableIndirect {
  574. // CHECK:STDOUT: !entry:
  575. // CHECK:STDOUT: name_binding_decl {
  576. // CHECK:STDOUT: %b.patt: %AdaptNoncopyableIndirect = binding_pattern b
  577. // CHECK:STDOUT: %.loc20_3.1: %AdaptNoncopyableIndirect = var_pattern %b.patt
  578. // CHECK:STDOUT: }
  579. // CHECK:STDOUT: %b.var: ref %AdaptNoncopyableIndirect = var b
  580. // CHECK:STDOUT: %a.ref: %AdaptNoncopyableIndirect = name_ref a, %a
  581. // CHECK:STDOUT: %.loc20_3.2: %tuple.type.c9a = as_compatible %a.ref
  582. // CHECK:STDOUT: %tuple.elem0.loc20_3.1: %i32 = tuple_access %.loc20_3.2, element0
  583. // CHECK:STDOUT: %.loc20_3.3: ref %tuple.type.c9a = as_compatible %b.var
  584. // CHECK:STDOUT: %tuple.elem0.loc20_3.2: ref %i32 = tuple_access %.loc20_3.3, element0
  585. // CHECK:STDOUT: %.loc20_3.4: init %i32 = initialize_from %tuple.elem0.loc20_3.1 to %tuple.elem0.loc20_3.2
  586. // CHECK:STDOUT: %tuple.elem1.loc20: %Noncopyable = tuple_access %.loc20_3.2, element1
  587. // CHECK:STDOUT: assign %b.var, <error>
  588. // CHECK:STDOUT: %AdaptNoncopyableIndirect.ref.loc20: type = name_ref AdaptNoncopyableIndirect, file.%AdaptNoncopyableIndirect.decl [template = constants.%AdaptNoncopyableIndirect]
  589. // CHECK:STDOUT: %b: ref %AdaptNoncopyableIndirect = bind_name b, %b.var
  590. // CHECK:STDOUT: %b.ref: ref %AdaptNoncopyableIndirect = name_ref b, %b
  591. // CHECK:STDOUT: %.loc28_11.1: ref %tuple.type.c9a = as_compatible %b.ref
  592. // CHECK:STDOUT: %tuple.elem0.loc28_11.1: ref %i32 = tuple_access %.loc28_11.1, element0
  593. // CHECK:STDOUT: %.loc28_11.2: %i32 = bind_value %tuple.elem0.loc28_11.1
  594. // CHECK:STDOUT: %.loc28_11.3: ref %tuple.type.c9a = as_compatible %return
  595. // CHECK:STDOUT: %tuple.elem0.loc28_11.2: ref %i32 = tuple_access %.loc28_11.3, element0
  596. // CHECK:STDOUT: %.loc28_11.4: init %i32 = initialize_from %.loc28_11.2 to %tuple.elem0.loc28_11.2
  597. // CHECK:STDOUT: %tuple.elem1.loc28: ref %Noncopyable = tuple_access %.loc28_11.1, element1
  598. // CHECK:STDOUT: %.loc28_11.5: %Noncopyable = bind_value %tuple.elem1.loc28
  599. // CHECK:STDOUT: return <error> to %return
  600. // CHECK:STDOUT: }
  601. // CHECK:STDOUT:
  602. // CHECK:STDOUT: --- adapt_copyable_struct.carbon
  603. // CHECK:STDOUT:
  604. // CHECK:STDOUT: constants {
  605. // CHECK:STDOUT: %AdaptStruct: type = class_type @AdaptStruct [template]
  606. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  607. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  608. // CHECK:STDOUT: %struct_type.e.f: type = struct_type {.e: %i32, .f: %i32} [template]
  609. // CHECK:STDOUT: %complete_type.511: <witness> = complete_type_witness %struct_type.e.f [template]
  610. // CHECK:STDOUT: %I.type: type = fn_type @I [template]
  611. // CHECK:STDOUT: %I: %I.type = struct_value () [template]
  612. // CHECK:STDOUT: %u32: type = class_type @UInt, @UInt(%int_32) [template]
  613. // CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template]
  614. // CHECK:STDOUT: %tuple.type.80b: type = tuple_type (%AdaptStruct, %u32) [template]
  615. // CHECK:STDOUT: %InTuple.type: type = fn_type @InTuple [template]
  616. // CHECK:STDOUT: %InTuple: %InTuple.type = struct_value () [template]
  617. // CHECK:STDOUT: }
  618. // CHECK:STDOUT:
  619. // CHECK:STDOUT: imports {
  620. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  621. // CHECK:STDOUT: .Int = %Core.Int
  622. // CHECK:STDOUT: .UInt = %Core.UInt
  623. // CHECK:STDOUT: import Core//prelude
  624. // CHECK:STDOUT: import Core//prelude/...
  625. // CHECK:STDOUT: }
  626. // CHECK:STDOUT: }
  627. // CHECK:STDOUT:
  628. // CHECK:STDOUT: file {
  629. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  630. // CHECK:STDOUT: .Core = imports.%Core
  631. // CHECK:STDOUT: .AdaptStruct = %AdaptStruct.decl
  632. // CHECK:STDOUT: .I = %I.decl
  633. // CHECK:STDOUT: .InTuple = %InTuple.decl
  634. // CHECK:STDOUT: }
  635. // CHECK:STDOUT: %Core.import = import Core
  636. // CHECK:STDOUT: %AdaptStruct.decl: type = class_decl @AdaptStruct [template = constants.%AdaptStruct] {} {}
  637. // CHECK:STDOUT: %I.decl: %I.type = fn_decl @I [template = constants.%I] {
  638. // CHECK:STDOUT: %g.patt: %AdaptStruct = binding_pattern g
  639. // CHECK:STDOUT: %g.param_patt: %AdaptStruct = value_param_pattern %g.patt, runtime_param0
  640. // CHECK:STDOUT: %return.patt: %AdaptStruct = return_slot_pattern
  641. // CHECK:STDOUT: %return.param_patt: %AdaptStruct = out_param_pattern %return.patt, runtime_param1
  642. // CHECK:STDOUT: } {
  643. // CHECK:STDOUT: %AdaptStruct.ref.loc8_25: type = name_ref AdaptStruct, file.%AdaptStruct.decl [template = constants.%AdaptStruct]
  644. // CHECK:STDOUT: %g.param: %AdaptStruct = value_param runtime_param0
  645. // CHECK:STDOUT: %AdaptStruct.ref.loc8_9: type = name_ref AdaptStruct, file.%AdaptStruct.decl [template = constants.%AdaptStruct]
  646. // CHECK:STDOUT: %g: %AdaptStruct = bind_name g, %g.param
  647. // CHECK:STDOUT: %return.param: ref %AdaptStruct = out_param runtime_param1
  648. // CHECK:STDOUT: %return: ref %AdaptStruct = return_slot %return.param
  649. // CHECK:STDOUT: }
  650. // CHECK:STDOUT: %InTuple.decl: %InTuple.type = fn_decl @InTuple [template = constants.%InTuple] {
  651. // CHECK:STDOUT: %c.patt: %tuple.type.80b = binding_pattern c
  652. // CHECK:STDOUT: %c.param_patt: %tuple.type.80b = value_param_pattern %c.patt, runtime_param0
  653. // CHECK:STDOUT: %return.patt: %tuple.type.80b = return_slot_pattern
  654. // CHECK:STDOUT: %return.param_patt: %tuple.type.80b = out_param_pattern %return.patt, runtime_param1
  655. // CHECK:STDOUT: } {
  656. // CHECK:STDOUT: %AdaptStruct.ref.loc13_39: type = name_ref AdaptStruct, file.%AdaptStruct.decl [template = constants.%AdaptStruct]
  657. // CHECK:STDOUT: %int_32.loc13_52: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  658. // CHECK:STDOUT: %u32.loc13_52: type = class_type @UInt, @UInt(constants.%int_32) [template = constants.%u32]
  659. // CHECK:STDOUT: %.loc13_55.1: %tuple.type.24b = tuple_literal (%AdaptStruct.ref.loc13_39, %u32.loc13_52)
  660. // CHECK:STDOUT: %.loc13_55.2: type = converted %.loc13_55.1, constants.%tuple.type.80b [template = constants.%tuple.type.80b]
  661. // CHECK:STDOUT: %c.param: %tuple.type.80b = value_param runtime_param0
  662. // CHECK:STDOUT: %.loc13_32.1: type = splice_block %.loc13_32.3 [template = constants.%tuple.type.80b] {
  663. // CHECK:STDOUT: %AdaptStruct.ref.loc13_16: type = name_ref AdaptStruct, file.%AdaptStruct.decl [template = constants.%AdaptStruct]
  664. // CHECK:STDOUT: %int_32.loc13_29: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  665. // CHECK:STDOUT: %u32.loc13_29: type = class_type @UInt, @UInt(constants.%int_32) [template = constants.%u32]
  666. // CHECK:STDOUT: %.loc13_32.2: %tuple.type.24b = tuple_literal (%AdaptStruct.ref.loc13_16, %u32.loc13_29)
  667. // CHECK:STDOUT: %.loc13_32.3: type = converted %.loc13_32.2, constants.%tuple.type.80b [template = constants.%tuple.type.80b]
  668. // CHECK:STDOUT: }
  669. // CHECK:STDOUT: %c: %tuple.type.80b = bind_name c, %c.param
  670. // CHECK:STDOUT: %return.param: ref %tuple.type.80b = out_param runtime_param1
  671. // CHECK:STDOUT: %return: ref %tuple.type.80b = return_slot %return.param
  672. // CHECK:STDOUT: }
  673. // CHECK:STDOUT: }
  674. // CHECK:STDOUT:
  675. // CHECK:STDOUT: class @AdaptStruct {
  676. // CHECK:STDOUT: %int_32.loc5_14: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  677. // CHECK:STDOUT: %i32.loc5_14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  678. // CHECK:STDOUT: %int_32.loc5_23: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  679. // CHECK:STDOUT: %i32.loc5_23: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  680. // CHECK:STDOUT: %struct_type.e.f: type = struct_type {.e: %i32, .f: %i32} [template = constants.%struct_type.e.f]
  681. // CHECK:STDOUT: adapt_decl %struct_type.e.f [template]
  682. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.e.f [template = constants.%complete_type.511]
  683. // CHECK:STDOUT: complete_type_witness = %complete_type
  684. // CHECK:STDOUT:
  685. // CHECK:STDOUT: !members:
  686. // CHECK:STDOUT: .Self = constants.%AdaptStruct
  687. // CHECK:STDOUT: }
  688. // CHECK:STDOUT:
  689. // CHECK:STDOUT: fn @I(%g.param_patt: %AdaptStruct) -> %return.param_patt: %AdaptStruct {
  690. // CHECK:STDOUT: !entry:
  691. // CHECK:STDOUT: name_binding_decl {
  692. // CHECK:STDOUT: %h.patt: %AdaptStruct = binding_pattern h
  693. // CHECK:STDOUT: %.loc9_3.1: %AdaptStruct = var_pattern %h.patt
  694. // CHECK:STDOUT: }
  695. // CHECK:STDOUT: %h.var: ref %AdaptStruct = var h
  696. // CHECK:STDOUT: %g.ref: %AdaptStruct = name_ref g, %g
  697. // CHECK:STDOUT: %.loc9_3.2: %struct_type.e.f = as_compatible %g.ref
  698. // CHECK:STDOUT: %.loc9_3.3: %i32 = struct_access %.loc9_3.2, element0
  699. // CHECK:STDOUT: %.loc9_3.4: ref %struct_type.e.f = as_compatible %h.var
  700. // CHECK:STDOUT: %.loc9_3.5: ref %i32 = struct_access %.loc9_3.4, element0
  701. // CHECK:STDOUT: %.loc9_3.6: init %i32 = initialize_from %.loc9_3.3 to %.loc9_3.5
  702. // CHECK:STDOUT: %.loc9_3.7: %i32 = struct_access %.loc9_3.2, element1
  703. // CHECK:STDOUT: %.loc9_3.8: ref %i32 = struct_access %.loc9_3.4, element1
  704. // CHECK:STDOUT: %.loc9_3.9: init %i32 = initialize_from %.loc9_3.7 to %.loc9_3.8
  705. // CHECK:STDOUT: %.loc9_3.10: init %struct_type.e.f = struct_init (%.loc9_3.6, %.loc9_3.9) to %.loc9_3.4
  706. // CHECK:STDOUT: %.loc9_3.11: init %AdaptStruct = as_compatible %.loc9_3.10
  707. // CHECK:STDOUT: %.loc9_3.12: init %AdaptStruct = converted %g.ref, %.loc9_3.11
  708. // CHECK:STDOUT: assign %h.var, %.loc9_3.12
  709. // CHECK:STDOUT: %AdaptStruct.ref.loc9: type = name_ref AdaptStruct, file.%AdaptStruct.decl [template = constants.%AdaptStruct]
  710. // CHECK:STDOUT: %h: ref %AdaptStruct = bind_name h, %h.var
  711. // CHECK:STDOUT: %h.ref: ref %AdaptStruct = name_ref h, %h
  712. // CHECK:STDOUT: %.loc10_11.1: ref %struct_type.e.f = as_compatible %h.ref
  713. // CHECK:STDOUT: %.loc10_11.2: ref %i32 = struct_access %.loc10_11.1, element0
  714. // CHECK:STDOUT: %.loc10_11.3: %i32 = bind_value %.loc10_11.2
  715. // CHECK:STDOUT: %.loc10_11.4: ref %struct_type.e.f = as_compatible %return
  716. // CHECK:STDOUT: %.loc10_11.5: ref %i32 = struct_access %.loc10_11.4, element0
  717. // CHECK:STDOUT: %.loc10_11.6: init %i32 = initialize_from %.loc10_11.3 to %.loc10_11.5
  718. // CHECK:STDOUT: %.loc10_11.7: ref %i32 = struct_access %.loc10_11.1, element1
  719. // CHECK:STDOUT: %.loc10_11.8: %i32 = bind_value %.loc10_11.7
  720. // CHECK:STDOUT: %.loc10_11.9: ref %i32 = struct_access %.loc10_11.4, element1
  721. // CHECK:STDOUT: %.loc10_11.10: init %i32 = initialize_from %.loc10_11.8 to %.loc10_11.9
  722. // CHECK:STDOUT: %.loc10_11.11: init %struct_type.e.f = struct_init (%.loc10_11.6, %.loc10_11.10) to %.loc10_11.4
  723. // CHECK:STDOUT: %.loc10_11.12: init %AdaptStruct = as_compatible %.loc10_11.11
  724. // CHECK:STDOUT: %.loc10_11.13: init %AdaptStruct = converted %h.ref, %.loc10_11.12
  725. // CHECK:STDOUT: return %.loc10_11.13 to %return
  726. // CHECK:STDOUT: }
  727. // CHECK:STDOUT:
  728. // CHECK:STDOUT: fn @InTuple(%c.param_patt: %tuple.type.80b) -> %return.param_patt: %tuple.type.80b {
  729. // CHECK:STDOUT: !entry:
  730. // CHECK:STDOUT: name_binding_decl {
  731. // CHECK:STDOUT: %d.patt: %tuple.type.80b = binding_pattern d
  732. // CHECK:STDOUT: %.loc14_3.1: %tuple.type.80b = var_pattern %d.patt
  733. // CHECK:STDOUT: }
  734. // CHECK:STDOUT: %d.var: ref %tuple.type.80b = var d
  735. // CHECK:STDOUT: %c.ref: %tuple.type.80b = name_ref c, %c
  736. // CHECK:STDOUT: %tuple.elem0.loc14_31.1: %AdaptStruct = tuple_access %c.ref, element0
  737. // CHECK:STDOUT: %.loc14_31.1: %struct_type.e.f = as_compatible %tuple.elem0.loc14_31.1
  738. // CHECK:STDOUT: %.loc14_31.2: %i32 = struct_access %.loc14_31.1, element0
  739. // CHECK:STDOUT: %tuple.elem0.loc14_31.2: ref %AdaptStruct = tuple_access %d.var, element0
  740. // CHECK:STDOUT: %.loc14_31.3: ref %struct_type.e.f = as_compatible %tuple.elem0.loc14_31.2
  741. // CHECK:STDOUT: %.loc14_31.4: ref %i32 = struct_access %.loc14_31.3, element0
  742. // CHECK:STDOUT: %.loc14_31.5: init %i32 = initialize_from %.loc14_31.2 to %.loc14_31.4
  743. // CHECK:STDOUT: %.loc14_31.6: %i32 = struct_access %.loc14_31.1, element1
  744. // CHECK:STDOUT: %.loc14_31.7: ref %i32 = struct_access %.loc14_31.3, element1
  745. // CHECK:STDOUT: %.loc14_31.8: init %i32 = initialize_from %.loc14_31.6 to %.loc14_31.7
  746. // CHECK:STDOUT: %.loc14_31.9: init %struct_type.e.f = struct_init (%.loc14_31.5, %.loc14_31.8) to %.loc14_31.3
  747. // CHECK:STDOUT: %.loc14_31.10: init %AdaptStruct = as_compatible %.loc14_31.9
  748. // CHECK:STDOUT: %.loc14_31.11: init %AdaptStruct = converted %tuple.elem0.loc14_31.1, %.loc14_31.10
  749. // CHECK:STDOUT: %tuple.elem1.loc14_31.1: %u32 = tuple_access %c.ref, element1
  750. // CHECK:STDOUT: %tuple.elem1.loc14_31.2: ref %u32 = tuple_access %d.var, element1
  751. // CHECK:STDOUT: %.loc14_31.12: init %u32 = initialize_from %tuple.elem1.loc14_31.1 to %tuple.elem1.loc14_31.2
  752. // CHECK:STDOUT: %.loc14_31.13: init %tuple.type.80b = tuple_init (%.loc14_31.11, %.loc14_31.12) to %d.var
  753. // CHECK:STDOUT: %.loc14_3.2: init %tuple.type.80b = converted %c.ref, %.loc14_31.13
  754. // CHECK:STDOUT: assign %d.var, %.loc14_3.2
  755. // CHECK:STDOUT: %.loc14_27.1: type = splice_block %.loc14_27.3 [template = constants.%tuple.type.80b] {
  756. // CHECK:STDOUT: %AdaptStruct.ref.loc14: type = name_ref AdaptStruct, file.%AdaptStruct.decl [template = constants.%AdaptStruct]
  757. // CHECK:STDOUT: %int_32.loc14: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  758. // CHECK:STDOUT: %u32.loc14: type = class_type @UInt, @UInt(constants.%int_32) [template = constants.%u32]
  759. // CHECK:STDOUT: %.loc14_27.2: %tuple.type.24b = tuple_literal (%AdaptStruct.ref.loc14, %u32.loc14)
  760. // CHECK:STDOUT: %.loc14_27.3: type = converted %.loc14_27.2, constants.%tuple.type.80b [template = constants.%tuple.type.80b]
  761. // CHECK:STDOUT: }
  762. // CHECK:STDOUT: %d: ref %tuple.type.80b = bind_name d, %d.var
  763. // CHECK:STDOUT: %d.ref: ref %tuple.type.80b = name_ref d, %d
  764. // CHECK:STDOUT: %tuple.elem0.loc15_10.1: ref %AdaptStruct = tuple_access %d.ref, element0
  765. // CHECK:STDOUT: %.loc15_10.1: ref %struct_type.e.f = as_compatible %tuple.elem0.loc15_10.1
  766. // CHECK:STDOUT: %.loc15_10.2: ref %i32 = struct_access %.loc15_10.1, element0
  767. // CHECK:STDOUT: %.loc15_10.3: %i32 = bind_value %.loc15_10.2
  768. // CHECK:STDOUT: %tuple.elem0.loc15_10.2: ref %AdaptStruct = tuple_access %return, element0
  769. // CHECK:STDOUT: %.loc15_10.4: ref %struct_type.e.f = as_compatible %tuple.elem0.loc15_10.2
  770. // CHECK:STDOUT: %.loc15_10.5: ref %i32 = struct_access %.loc15_10.4, element0
  771. // CHECK:STDOUT: %.loc15_10.6: init %i32 = initialize_from %.loc15_10.3 to %.loc15_10.5
  772. // CHECK:STDOUT: %.loc15_10.7: ref %i32 = struct_access %.loc15_10.1, element1
  773. // CHECK:STDOUT: %.loc15_10.8: %i32 = bind_value %.loc15_10.7
  774. // CHECK:STDOUT: %.loc15_10.9: ref %i32 = struct_access %.loc15_10.4, element1
  775. // CHECK:STDOUT: %.loc15_10.10: init %i32 = initialize_from %.loc15_10.8 to %.loc15_10.9
  776. // CHECK:STDOUT: %.loc15_10.11: init %struct_type.e.f = struct_init (%.loc15_10.6, %.loc15_10.10) to %.loc15_10.4
  777. // CHECK:STDOUT: %.loc15_10.12: init %AdaptStruct = as_compatible %.loc15_10.11
  778. // CHECK:STDOUT: %.loc15_10.13: init %AdaptStruct = converted %tuple.elem0.loc15_10.1, %.loc15_10.12
  779. // CHECK:STDOUT: %tuple.elem1.loc15_10.1: ref %u32 = tuple_access %d.ref, element1
  780. // CHECK:STDOUT: %.loc15_10.14: %u32 = bind_value %tuple.elem1.loc15_10.1
  781. // CHECK:STDOUT: %tuple.elem1.loc15_10.2: ref %u32 = tuple_access %return, element1
  782. // CHECK:STDOUT: %.loc15_10.15: init %u32 = initialize_from %.loc15_10.14 to %tuple.elem1.loc15_10.2
  783. // CHECK:STDOUT: %.loc15_10.16: init %tuple.type.80b = tuple_init (%.loc15_10.13, %.loc15_10.15) to %return
  784. // CHECK:STDOUT: %.loc15_11: init %tuple.type.80b = converted %d.ref, %.loc15_10.16
  785. // CHECK:STDOUT: return %.loc15_11 to %return
  786. // CHECK:STDOUT: }
  787. // CHECK:STDOUT: