equal_rewrite.carbon 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/primitives.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/where_expr/equal_rewrite.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/where_expr/equal_rewrite.carbon
  12. // --- equal_constraint.carbon
  13. library "[[@TEST_NAME]]";
  14. interface N {
  15. let P:! type;
  16. }
  17. //@dump-sem-ir-begin
  18. fn Equal(T:! N where .P = {});
  19. //@dump-sem-ir-end
  20. // --- nested_rewrites.carbon
  21. library "[[@TEST_NAME]]";
  22. interface A {
  23. let B:! type;
  24. let C:! type;
  25. }
  26. //@dump-sem-ir-begin
  27. fn NestedRewrite(D:! (A where .B = bool) where .C = ());
  28. //@dump-sem-ir-end
  29. // --- repeated_rewrite.carbon
  30. library "[[@TEST_NAME]]";
  31. interface E {
  32. let F:! type;
  33. }
  34. //@dump-sem-ir-begin
  35. fn OneRewrite(G:! E where .F = i32) {}
  36. fn RepeatedRewrite(H:! E where .F = i32 and .F = i32) {
  37. //@dump-sem-ir-end
  38. OneRewrite(H);
  39. }
  40. fn OneRewriteAgain(I:! E where .F = i32) {
  41. RepeatedRewrite(I);
  42. }
  43. // --- rewrites_reordered.carbon
  44. library "[[@TEST_NAME]]";
  45. interface J {
  46. let K:! type;
  47. let L:! type;
  48. }
  49. //@dump-sem-ir-begin
  50. fn Alphabetical(M:! J where .K = () and .L = bool) {}
  51. fn Reversed(N:! J where .L = bool and .K = ()) {
  52. //@dump-sem-ir-end
  53. Alphabetical(N);
  54. }
  55. // --- fail_rewrites_mismatch_right.carbon
  56. library "[[@TEST_NAME]]";
  57. interface O {
  58. let P:! type;
  59. }
  60. fn WithInteger(Q:! O where .P = i32) {}
  61. fn WithBool(R:! O where .P = bool) {
  62. // CHECK:STDERR: fail_rewrites_mismatch_right.carbon:[[@LINE+7]]:3: error: cannot convert type `R` that implements `O where .(O.P) = bool` into type implementing `O where .(O.P) = i32` [ConversionFailureFacetToFacet]
  63. // CHECK:STDERR: WithInteger(R);
  64. // CHECK:STDERR: ^~~~~~~~~~~~~~
  65. // CHECK:STDERR: fail_rewrites_mismatch_right.carbon:[[@LINE-6]]:16: note: initializing generic parameter `Q` declared here [InitializingGenericParam]
  66. // CHECK:STDERR: fn WithInteger(Q:! O where .P = i32) {}
  67. // CHECK:STDERR: ^
  68. // CHECK:STDERR:
  69. WithInteger(R);
  70. }
  71. // --- fail_rewrites_mismatch_left.carbon
  72. library "[[@TEST_NAME]]";
  73. interface S {
  74. let T:! type;
  75. let U:! type;
  76. }
  77. fn WithT(V:! S where .T = ()) {}
  78. fn WithU(W:! S where .U = ()) {
  79. // CHECK:STDERR: fail_rewrites_mismatch_left.carbon:[[@LINE+7]]:3: error: cannot convert type `W` that implements `S where .(S.U) = ()` into type implementing `S where .(S.T) = ()` [ConversionFailureFacetToFacet]
  80. // CHECK:STDERR: WithT(W);
  81. // CHECK:STDERR: ^~~~~~~~
  82. // CHECK:STDERR: fail_rewrites_mismatch_left.carbon:[[@LINE-6]]:10: note: initializing generic parameter `V` declared here [InitializingGenericParam]
  83. // CHECK:STDERR: fn WithT(V:! S where .T = ()) {}
  84. // CHECK:STDERR: ^
  85. // CHECK:STDERR:
  86. WithT(W);
  87. }
  88. // --- fail_import_rewrites.carbon
  89. library "[[@TEST_NAME]]";
  90. import library "equal_constraint";
  91. import library "nested_rewrites";
  92. fn Calls() {
  93. // CHECK:STDERR: fail_import_rewrites.carbon:[[@LINE+8]]:3: error: cannot convert type `bool` into type implementing `N where .(N.P) = {}` [ConversionFailureTypeToFacet]
  94. // CHECK:STDERR: Equal(bool);
  95. // CHECK:STDERR: ^~~~~~~~~~~
  96. // CHECK:STDERR: fail_import_rewrites.carbon:[[@LINE-7]]:1: in import [InImport]
  97. // CHECK:STDERR: equal_constraint.carbon:9:10: note: initializing generic parameter `T` declared here [InitializingGenericParam]
  98. // CHECK:STDERR: fn Equal(T:! N where .P = {});
  99. // CHECK:STDERR: ^
  100. // CHECK:STDERR:
  101. Equal(bool);
  102. // CHECK:STDERR: fail_import_rewrites.carbon:[[@LINE+8]]:3: error: cannot convert type `i32` into type implementing `A where .(A.C) = () and .(A.B) = bool` [ConversionFailureTypeToFacet]
  103. // CHECK:STDERR: NestedRewrite(i32);
  104. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
  105. // CHECK:STDERR: fail_import_rewrites.carbon:[[@LINE-17]]:1: in import [InImport]
  106. // CHECK:STDERR: nested_rewrites.carbon:10:18: note: initializing generic parameter `D` declared here [InitializingGenericParam]
  107. // CHECK:STDERR: fn NestedRewrite(D:! (A where .B = bool) where .C = ());
  108. // CHECK:STDERR: ^
  109. // CHECK:STDERR:
  110. NestedRewrite(i32);
  111. }
  112. // --- fail_check_rewrite_constraints.carbon
  113. library "[[@TEST_NAME]]";
  114. interface I {
  115. let Member:! type;
  116. }
  117. // `2` can't be converted to the type of `I.Member`
  118. // CHECK:STDERR: fail_check_rewrite_constraints.carbon:[[@LINE+7]]:46: error: cannot implicitly convert non-type value of type `Core.IntLiteral` to `type` [ConversionFailureNonTypeToFacet]
  119. // CHECK:STDERR: fn RewriteTypeMismatch(X:! I where .Member = 2);
  120. // CHECK:STDERR: ^
  121. // CHECK:STDERR: fail_check_rewrite_constraints.carbon:[[@LINE+4]]:46: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote]
  122. // CHECK:STDERR: fn RewriteTypeMismatch(X:! I where .Member = 2);
  123. // CHECK:STDERR: ^
  124. // CHECK:STDERR:
  125. fn RewriteTypeMismatch(X:! I where .Member = 2);
  126. // --- todo_let.carbon
  127. library "[[@TEST_NAME]]";
  128. interface A {}
  129. class D {}
  130. impl D as A {}
  131. // TODO: This should be a compile-time binding, once that is supported at file scope.
  132. let B: type where .Self impls A = D;
  133. fn F() {
  134. let E:! type where .Self impls A = D;
  135. }
  136. // --- fail_todo_let_compile_time.carbon
  137. library "[[@TEST_NAME]]";
  138. interface A {}
  139. class D {}
  140. impl D as A {}
  141. // TODO: Compile-time binding are not yet supported at file scope.
  142. // CHECK:STDERR: fail_todo_let_compile_time.carbon:[[@LINE+4]]:5: error: semantics TODO: ``let` compile time binding outside function or interface` [SemanticsTodo]
  143. // CHECK:STDERR: let B:! type where .Self impls A = D;
  144. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  145. // CHECK:STDERR:
  146. let B:! type where .Self impls A = D;
  147. // --- fail_type_does_not_implement_where.carbon
  148. library "[[@TEST_NAME]]";
  149. interface E {
  150. let F:! type;
  151. let G:! type;
  152. }
  153. // Testing how these types get stringified in error messages.
  154. // TODO: This should be a compile-time binding, once that is supported.
  155. // CHECK:STDERR: fail_type_does_not_implement_where.carbon:[[@LINE+4]]:42: error: cannot convert type `f64` into type implementing `E where .(E.F) = bool and .(E.G) = ()` [ConversionFailureTypeToFacet]
  156. // CHECK:STDERR: let H: (E where .F = bool and .G = ()) = f64;
  157. // CHECK:STDERR: ^~~
  158. // CHECK:STDERR:
  159. let H: (E where .F = bool and .G = ()) = f64;
  160. // CHECK:STDERR: fail_type_does_not_implement_where.carbon:[[@LINE+4]]:45: error: cannot convert type `bool` into type implementing `E where .(E.F) = {} and .(E.G) = i32` [ConversionFailureTypeToFacet]
  161. // CHECK:STDERR: let J: ((E where .F = {}) where .G = i32) = bool;
  162. // CHECK:STDERR: ^~~~
  163. // CHECK:STDERR:
  164. let J: ((E where .F = {}) where .G = i32) = bool;
  165. // CHECK:STDERR: fail_type_does_not_implement_where.carbon:[[@LINE+4]]:33: error: cannot convert type `bool` into type implementing `E where .(E.F) = .(E.G)` [ConversionFailureTypeToFacet]
  166. // CHECK:STDERR: let K: (E where .F = .Self.G) = bool;
  167. // CHECK:STDERR: ^~~~
  168. // CHECK:STDERR:
  169. let K: (E where .F = .Self.G) = bool;
  170. // CHECK:STDOUT: --- equal_constraint.carbon
  171. // CHECK:STDOUT:
  172. // CHECK:STDOUT: constants {
  173. // CHECK:STDOUT: %N.type: type = facet_type <@N> [concrete]
  174. // CHECK:STDOUT: %N.assoc_type: type = assoc_entity_type @N [concrete]
  175. // CHECK:STDOUT: %assoc0: %N.assoc_type = assoc_entity element0, @N.%P [concrete]
  176. // CHECK:STDOUT: %.Self.89b: %N.type = bind_symbolic_name .Self [symbolic_self]
  177. // CHECK:STDOUT: %.Self.binding.as_type: type = symbolic_binding_type .Self, %.Self.89b [symbolic_self]
  178. // CHECK:STDOUT: %N.lookup_impl_witness: <witness> = lookup_impl_witness %.Self.89b, @N [symbolic_self]
  179. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access %N.lookup_impl_witness, element0 [symbolic_self]
  180. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  181. // CHECK:STDOUT: %N_where.type: type = facet_type <@N where %impl.elem0 = %empty_struct_type> [concrete]
  182. // CHECK:STDOUT: %T: %N_where.type = bind_symbolic_name T, 0 [symbolic]
  183. // CHECK:STDOUT: %pattern_type: type = pattern_type %N_where.type [concrete]
  184. // CHECK:STDOUT: %Equal.type: type = fn_type @Equal [concrete]
  185. // CHECK:STDOUT: %Equal: %Equal.type = struct_value () [concrete]
  186. // CHECK:STDOUT: }
  187. // CHECK:STDOUT:
  188. // CHECK:STDOUT: imports {
  189. // CHECK:STDOUT: }
  190. // CHECK:STDOUT:
  191. // CHECK:STDOUT: file {
  192. // CHECK:STDOUT: %Equal.decl: %Equal.type = fn_decl @Equal [concrete = constants.%Equal] {
  193. // CHECK:STDOUT: %T.patt: %pattern_type = symbolic_binding_pattern T, 0 [concrete]
  194. // CHECK:STDOUT: } {
  195. // CHECK:STDOUT: %.loc9_16.1: type = splice_block %.loc9_16.2 [concrete = constants.%N_where.type] {
  196. // CHECK:STDOUT: <elided>
  197. // CHECK:STDOUT: %N.ref: type = name_ref N, file.%N.decl [concrete = constants.%N.type]
  198. // CHECK:STDOUT: <elided>
  199. // CHECK:STDOUT: %.Self.ref: %N.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.89b]
  200. // CHECK:STDOUT: %P.ref: %N.assoc_type = name_ref P, @P.%assoc0 [concrete = constants.%assoc0]
  201. // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self.ref [symbolic_self = constants.%.Self.binding.as_type]
  202. // CHECK:STDOUT: %.loc9_22: type = converted %.Self.ref, %.Self.as_type [symbolic_self = constants.%.Self.binding.as_type]
  203. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access constants.%N.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
  204. // CHECK:STDOUT: %.loc9_28.1: %empty_struct_type = struct_literal ()
  205. // CHECK:STDOUT: %.loc9_28.2: type = converted %.loc9_28.1, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  206. // CHECK:STDOUT: %.loc9_16.2: type = where_expr %.Self.2 [concrete = constants.%N_where.type] {
  207. // CHECK:STDOUT: requirement_base_facet_type constants.%N.type
  208. // CHECK:STDOUT: requirement_rewrite %impl.elem0, %.loc9_28.2
  209. // CHECK:STDOUT: }
  210. // CHECK:STDOUT: }
  211. // CHECK:STDOUT: %T.loc9_10.2: %N_where.type = bind_symbolic_name T, 0 [symbolic = %T.loc9_10.1 (constants.%T)]
  212. // CHECK:STDOUT: }
  213. // CHECK:STDOUT: }
  214. // CHECK:STDOUT:
  215. // CHECK:STDOUT: generic fn @Equal(%T.loc9_10.2: %N_where.type) {
  216. // CHECK:STDOUT: %T.loc9_10.1: %N_where.type = bind_symbolic_name T, 0 [symbolic = %T.loc9_10.1 (constants.%T)]
  217. // CHECK:STDOUT:
  218. // CHECK:STDOUT: fn();
  219. // CHECK:STDOUT: }
  220. // CHECK:STDOUT:
  221. // CHECK:STDOUT: specific @Equal(constants.%T) {
  222. // CHECK:STDOUT: %T.loc9_10.1 => constants.%T
  223. // CHECK:STDOUT: }
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: --- nested_rewrites.carbon
  226. // CHECK:STDOUT:
  227. // CHECK:STDOUT: constants {
  228. // CHECK:STDOUT: %A.type: type = facet_type <@A> [concrete]
  229. // CHECK:STDOUT: %A.assoc_type: type = assoc_entity_type @A [concrete]
  230. // CHECK:STDOUT: %assoc0: %A.assoc_type = assoc_entity element0, @A.%B [concrete]
  231. // CHECK:STDOUT: %assoc1: %A.assoc_type = assoc_entity element1, @A.%C [concrete]
  232. // CHECK:STDOUT: %.Self.56d: %A.type = bind_symbolic_name .Self [symbolic_self]
  233. // CHECK:STDOUT: %.Self.binding.as_type: type = symbolic_binding_type .Self, %.Self.56d [symbolic_self]
  234. // CHECK:STDOUT: %A.lookup_impl_witness: <witness> = lookup_impl_witness %.Self.56d, @A [symbolic_self]
  235. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access %A.lookup_impl_witness, element0 [symbolic_self]
  236. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [concrete]
  237. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [concrete]
  238. // CHECK:STDOUT: %A_where.type.02c: type = facet_type <@A where %impl.elem0 = bool> [concrete]
  239. // CHECK:STDOUT: %impl.elem1: type = impl_witness_access %A.lookup_impl_witness, element1 [symbolic_self]
  240. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  241. // CHECK:STDOUT: %A_where.type.e52: type = facet_type <@A where %impl.elem0 = bool and %impl.elem1 = %empty_tuple.type> [concrete]
  242. // CHECK:STDOUT: %D: %A_where.type.e52 = bind_symbolic_name D, 0 [symbolic]
  243. // CHECK:STDOUT: %pattern_type.04b: type = pattern_type %A_where.type.e52 [concrete]
  244. // CHECK:STDOUT: %NestedRewrite.type: type = fn_type @NestedRewrite [concrete]
  245. // CHECK:STDOUT: %NestedRewrite: %NestedRewrite.type = struct_value () [concrete]
  246. // CHECK:STDOUT: }
  247. // CHECK:STDOUT:
  248. // CHECK:STDOUT: imports {
  249. // CHECK:STDOUT: }
  250. // CHECK:STDOUT:
  251. // CHECK:STDOUT: file {
  252. // CHECK:STDOUT: %NestedRewrite.decl: %NestedRewrite.type = fn_decl @NestedRewrite [concrete = constants.%NestedRewrite] {
  253. // CHECK:STDOUT: %D.patt: %pattern_type.04b = symbolic_binding_pattern D, 0 [concrete]
  254. // CHECK:STDOUT: } {
  255. // CHECK:STDOUT: %.loc10_42.1: type = splice_block %.loc10_42.2 [concrete = constants.%A_where.type.e52] {
  256. // CHECK:STDOUT: <elided>
  257. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A.type]
  258. // CHECK:STDOUT: <elided>
  259. // CHECK:STDOUT: %.Self.ref.loc10_31: %A.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.56d]
  260. // CHECK:STDOUT: %B.ref: %A.assoc_type = name_ref B, @B.%assoc0 [concrete = constants.%assoc0]
  261. // CHECK:STDOUT: %.Self.as_type.loc10_31: type = facet_access_type %.Self.ref.loc10_31 [symbolic_self = constants.%.Self.binding.as_type]
  262. // CHECK:STDOUT: %.loc10_31: type = converted %.Self.ref.loc10_31, %.Self.as_type.loc10_31 [symbolic_self = constants.%.Self.binding.as_type]
  263. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access constants.%A.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
  264. // CHECK:STDOUT: %Bool.call: init type = call constants.%Bool() [concrete = bool]
  265. // CHECK:STDOUT: %.loc10_36.1: type = value_of_initializer %Bool.call [concrete = bool]
  266. // CHECK:STDOUT: %.loc10_36.2: type = converted %Bool.call, %.loc10_36.1 [concrete = bool]
  267. // CHECK:STDOUT: %.loc10_25: type = where_expr %.Self.2 [concrete = constants.%A_where.type.02c] {
  268. // CHECK:STDOUT: requirement_base_facet_type constants.%A.type
  269. // CHECK:STDOUT: requirement_rewrite %impl.elem0, %.loc10_36.2
  270. // CHECK:STDOUT: }
  271. // CHECK:STDOUT: <elided>
  272. // CHECK:STDOUT: %.Self.ref.loc10_48: %A.type = name_ref .Self, %.Self.3 [symbolic_self = constants.%.Self.56d]
  273. // CHECK:STDOUT: %C.ref: %A.assoc_type = name_ref C, @C.%assoc1 [concrete = constants.%assoc1]
  274. // CHECK:STDOUT: %.Self.as_type.loc10_48: type = facet_access_type %.Self.ref.loc10_48 [symbolic_self = constants.%.Self.binding.as_type]
  275. // CHECK:STDOUT: %.loc10_48: type = converted %.Self.ref.loc10_48, %.Self.as_type.loc10_48 [symbolic_self = constants.%.Self.binding.as_type]
  276. // CHECK:STDOUT: %impl.elem1: type = impl_witness_access constants.%A.lookup_impl_witness, element1 [symbolic_self = constants.%impl.elem1]
  277. // CHECK:STDOUT: %.loc10_54.1: %empty_tuple.type = tuple_literal ()
  278. // CHECK:STDOUT: %.loc10_54.2: type = converted %.loc10_54.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  279. // CHECK:STDOUT: %.loc10_42.2: type = where_expr %.Self.3 [concrete = constants.%A_where.type.e52] {
  280. // CHECK:STDOUT: requirement_base_facet_type constants.%A_where.type.02c
  281. // CHECK:STDOUT: requirement_rewrite %impl.elem1, %.loc10_54.2
  282. // CHECK:STDOUT: }
  283. // CHECK:STDOUT: }
  284. // CHECK:STDOUT: %D.loc10_18.2: %A_where.type.e52 = bind_symbolic_name D, 0 [symbolic = %D.loc10_18.1 (constants.%D)]
  285. // CHECK:STDOUT: }
  286. // CHECK:STDOUT: }
  287. // CHECK:STDOUT:
  288. // CHECK:STDOUT: generic fn @NestedRewrite(%D.loc10_18.2: %A_where.type.e52) {
  289. // CHECK:STDOUT: %D.loc10_18.1: %A_where.type.e52 = bind_symbolic_name D, 0 [symbolic = %D.loc10_18.1 (constants.%D)]
  290. // CHECK:STDOUT:
  291. // CHECK:STDOUT: fn();
  292. // CHECK:STDOUT: }
  293. // CHECK:STDOUT:
  294. // CHECK:STDOUT: specific @NestedRewrite(constants.%D) {
  295. // CHECK:STDOUT: %D.loc10_18.1 => constants.%D
  296. // CHECK:STDOUT: }
  297. // CHECK:STDOUT:
  298. // CHECK:STDOUT: --- repeated_rewrite.carbon
  299. // CHECK:STDOUT:
  300. // CHECK:STDOUT: constants {
  301. // CHECK:STDOUT: %E.type: type = facet_type <@E> [concrete]
  302. // CHECK:STDOUT: %E.assoc_type: type = assoc_entity_type @E [concrete]
  303. // CHECK:STDOUT: %assoc0: %E.assoc_type = assoc_entity element0, @E.%F [concrete]
  304. // CHECK:STDOUT: %.Self.ba7: %E.type = bind_symbolic_name .Self [symbolic_self]
  305. // CHECK:STDOUT: %.Self.binding.as_type: type = symbolic_binding_type .Self, %.Self.ba7 [symbolic_self]
  306. // CHECK:STDOUT: %E.lookup_impl_witness: <witness> = lookup_impl_witness %.Self.ba7, @E [symbolic_self]
  307. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access %E.lookup_impl_witness, element0 [symbolic_self]
  308. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  309. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  310. // CHECK:STDOUT: %E_where.type: type = facet_type <@E where %impl.elem0 = %i32> [concrete]
  311. // CHECK:STDOUT: %G: %E_where.type = bind_symbolic_name G, 0 [symbolic]
  312. // CHECK:STDOUT: %pattern_type.804: type = pattern_type %E_where.type [concrete]
  313. // CHECK:STDOUT: %OneRewrite.type: type = fn_type @OneRewrite [concrete]
  314. // CHECK:STDOUT: %OneRewrite: %OneRewrite.type = struct_value () [concrete]
  315. // CHECK:STDOUT: %H: %E_where.type = bind_symbolic_name H, 0 [symbolic]
  316. // CHECK:STDOUT: %RepeatedRewrite.type: type = fn_type @RepeatedRewrite [concrete]
  317. // CHECK:STDOUT: %RepeatedRewrite: %RepeatedRewrite.type = struct_value () [concrete]
  318. // CHECK:STDOUT: %I: %E_where.type = bind_symbolic_name I, 0 [symbolic]
  319. // CHECK:STDOUT: %OneRewrite.specific_fn.616d52.2: <specific function> = specific_function %OneRewrite, @OneRewrite(%I) [symbolic]
  320. // CHECK:STDOUT: }
  321. // CHECK:STDOUT:
  322. // CHECK:STDOUT: imports {
  323. // CHECK:STDOUT: }
  324. // CHECK:STDOUT:
  325. // CHECK:STDOUT: file {
  326. // CHECK:STDOUT: %OneRewrite.decl: %OneRewrite.type = fn_decl @OneRewrite [concrete = constants.%OneRewrite] {
  327. // CHECK:STDOUT: %G.patt: %pattern_type.804 = symbolic_binding_pattern G, 0 [concrete]
  328. // CHECK:STDOUT: } {
  329. // CHECK:STDOUT: %.loc9_21.1: type = splice_block %.loc9_21.2 [concrete = constants.%E_where.type] {
  330. // CHECK:STDOUT: <elided>
  331. // CHECK:STDOUT: %E.ref: type = name_ref E, file.%E.decl [concrete = constants.%E.type]
  332. // CHECK:STDOUT: <elided>
  333. // CHECK:STDOUT: %.Self.ref: %E.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.ba7]
  334. // CHECK:STDOUT: %F.ref: %E.assoc_type = name_ref F, @F.%assoc0 [concrete = constants.%assoc0]
  335. // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self.ref [symbolic_self = constants.%.Self.binding.as_type]
  336. // CHECK:STDOUT: %.loc9_27: type = converted %.Self.ref, %.Self.as_type [symbolic_self = constants.%.Self.binding.as_type]
  337. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access constants.%E.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
  338. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  339. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  340. // CHECK:STDOUT: %.loc9_21.2: type = where_expr %.Self.2 [concrete = constants.%E_where.type] {
  341. // CHECK:STDOUT: requirement_base_facet_type constants.%E.type
  342. // CHECK:STDOUT: requirement_rewrite %impl.elem0, %i32
  343. // CHECK:STDOUT: }
  344. // CHECK:STDOUT: }
  345. // CHECK:STDOUT: %G.loc9_15.2: %E_where.type = bind_symbolic_name G, 0 [symbolic = %G.loc9_15.1 (constants.%G)]
  346. // CHECK:STDOUT: }
  347. // CHECK:STDOUT: %RepeatedRewrite.decl: %RepeatedRewrite.type = fn_decl @RepeatedRewrite [concrete = constants.%RepeatedRewrite] {
  348. // CHECK:STDOUT: %H.patt: %pattern_type.804 = symbolic_binding_pattern H, 0 [concrete]
  349. // CHECK:STDOUT: } {
  350. // CHECK:STDOUT: %.loc11_26.1: type = splice_block %.loc11_26.2 [concrete = constants.%E_where.type] {
  351. // CHECK:STDOUT: <elided>
  352. // CHECK:STDOUT: %E.ref: type = name_ref E, file.%E.decl [concrete = constants.%E.type]
  353. // CHECK:STDOUT: <elided>
  354. // CHECK:STDOUT: %.Self.ref.loc11_32: %E.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.ba7]
  355. // CHECK:STDOUT: %F.ref.loc11_32: %E.assoc_type = name_ref F, @F.%assoc0 [concrete = constants.%assoc0]
  356. // CHECK:STDOUT: %.Self.as_type.loc11_32: type = facet_access_type %.Self.ref.loc11_32 [symbolic_self = constants.%.Self.binding.as_type]
  357. // CHECK:STDOUT: %.loc11_32: type = converted %.Self.ref.loc11_32, %.Self.as_type.loc11_32 [symbolic_self = constants.%.Self.binding.as_type]
  358. // CHECK:STDOUT: %impl.elem0.loc11_32: type = impl_witness_access constants.%E.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
  359. // CHECK:STDOUT: %int_32.loc11_37: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  360. // CHECK:STDOUT: %i32.loc11_37: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  361. // CHECK:STDOUT: %.Self.ref.loc11_45: %E.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.ba7]
  362. // CHECK:STDOUT: %F.ref.loc11_45: %E.assoc_type = name_ref F, @F.%assoc0 [concrete = constants.%assoc0]
  363. // CHECK:STDOUT: %.Self.as_type.loc11_45: type = facet_access_type %.Self.ref.loc11_45 [symbolic_self = constants.%.Self.binding.as_type]
  364. // CHECK:STDOUT: %.loc11_45: type = converted %.Self.ref.loc11_45, %.Self.as_type.loc11_45 [symbolic_self = constants.%.Self.binding.as_type]
  365. // CHECK:STDOUT: %impl.elem0.loc11_45: type = impl_witness_access constants.%E.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
  366. // CHECK:STDOUT: %impl.elem0.subst: type = impl_witness_access_substituted %impl.elem0.loc11_45, %i32.loc11_37 [concrete = constants.%i32]
  367. // CHECK:STDOUT: %int_32.loc11_50: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  368. // CHECK:STDOUT: %i32.loc11_50: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  369. // CHECK:STDOUT: %.loc11_26.2: type = where_expr %.Self.2 [concrete = constants.%E_where.type] {
  370. // CHECK:STDOUT: requirement_base_facet_type constants.%E.type
  371. // CHECK:STDOUT: requirement_rewrite %impl.elem0.loc11_32, %i32.loc11_37
  372. // CHECK:STDOUT: requirement_rewrite %impl.elem0.subst, %i32.loc11_50
  373. // CHECK:STDOUT: }
  374. // CHECK:STDOUT: }
  375. // CHECK:STDOUT: %H.loc11_20.2: %E_where.type = bind_symbolic_name H, 0 [symbolic = %H.loc11_20.1 (constants.%H)]
  376. // CHECK:STDOUT: }
  377. // CHECK:STDOUT: }
  378. // CHECK:STDOUT:
  379. // CHECK:STDOUT: generic fn @OneRewrite(%G.loc9_15.2: %E_where.type) {
  380. // CHECK:STDOUT: %G.loc9_15.1: %E_where.type = bind_symbolic_name G, 0 [symbolic = %G.loc9_15.1 (constants.%G)]
  381. // CHECK:STDOUT:
  382. // CHECK:STDOUT: !definition:
  383. // CHECK:STDOUT:
  384. // CHECK:STDOUT: fn() {
  385. // CHECK:STDOUT: !entry:
  386. // CHECK:STDOUT: return
  387. // CHECK:STDOUT: }
  388. // CHECK:STDOUT: }
  389. // CHECK:STDOUT:
  390. // CHECK:STDOUT: generic fn @RepeatedRewrite(%H.loc11_20.2: %E_where.type) {
  391. // CHECK:STDOUT: %H.loc11_20.1: %E_where.type = bind_symbolic_name H, 0 [symbolic = %H.loc11_20.1 (constants.%H)]
  392. // CHECK:STDOUT:
  393. // CHECK:STDOUT: !definition:
  394. // CHECK:STDOUT: <elided>
  395. // CHECK:STDOUT:
  396. // CHECK:STDOUT: fn() {
  397. // CHECK:STDOUT: !entry:
  398. // CHECK:STDOUT: <elided>
  399. // CHECK:STDOUT: }
  400. // CHECK:STDOUT: }
  401. // CHECK:STDOUT:
  402. // CHECK:STDOUT: specific @OneRewrite(constants.%G) {
  403. // CHECK:STDOUT: %G.loc9_15.1 => constants.%G
  404. // CHECK:STDOUT: }
  405. // CHECK:STDOUT:
  406. // CHECK:STDOUT: specific @RepeatedRewrite(constants.%H) {
  407. // CHECK:STDOUT: %H.loc11_20.1 => constants.%H
  408. // CHECK:STDOUT: }
  409. // CHECK:STDOUT:
  410. // CHECK:STDOUT: specific @OneRewrite(constants.%H) {
  411. // CHECK:STDOUT: %G.loc9_15.1 => constants.%H
  412. // CHECK:STDOUT:
  413. // CHECK:STDOUT: !definition:
  414. // CHECK:STDOUT: }
  415. // CHECK:STDOUT:
  416. // CHECK:STDOUT: specific @RepeatedRewrite(constants.%I) {
  417. // CHECK:STDOUT: %H.loc11_20.1 => constants.%I
  418. // CHECK:STDOUT:
  419. // CHECK:STDOUT: !definition:
  420. // CHECK:STDOUT: %OneRewrite.specific_fn.loc13_3.2 => constants.%OneRewrite.specific_fn.616d52.2
  421. // CHECK:STDOUT: }
  422. // CHECK:STDOUT:
  423. // CHECK:STDOUT: specific @OneRewrite(constants.%I) {
  424. // CHECK:STDOUT: %G.loc9_15.1 => constants.%I
  425. // CHECK:STDOUT:
  426. // CHECK:STDOUT: !definition:
  427. // CHECK:STDOUT: }
  428. // CHECK:STDOUT:
  429. // CHECK:STDOUT: --- rewrites_reordered.carbon
  430. // CHECK:STDOUT:
  431. // CHECK:STDOUT: constants {
  432. // CHECK:STDOUT: %J.type: type = facet_type <@J> [concrete]
  433. // CHECK:STDOUT: %J.assoc_type: type = assoc_entity_type @J [concrete]
  434. // CHECK:STDOUT: %assoc0: %J.assoc_type = assoc_entity element0, @J.%K [concrete]
  435. // CHECK:STDOUT: %assoc1: %J.assoc_type = assoc_entity element1, @J.%L [concrete]
  436. // CHECK:STDOUT: %.Self.e7c: %J.type = bind_symbolic_name .Self [symbolic_self]
  437. // CHECK:STDOUT: %.Self.binding.as_type: type = symbolic_binding_type .Self, %.Self.e7c [symbolic_self]
  438. // CHECK:STDOUT: %J.lookup_impl_witness: <witness> = lookup_impl_witness %.Self.e7c, @J [symbolic_self]
  439. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access %J.lookup_impl_witness, element0 [symbolic_self]
  440. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  441. // CHECK:STDOUT: %impl.elem1: type = impl_witness_access %J.lookup_impl_witness, element1 [symbolic_self]
  442. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [concrete]
  443. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [concrete]
  444. // CHECK:STDOUT: %J_where.type: type = facet_type <@J where %impl.elem0 = %empty_tuple.type and %impl.elem1 = bool> [concrete]
  445. // CHECK:STDOUT: %M: %J_where.type = bind_symbolic_name M, 0 [symbolic]
  446. // CHECK:STDOUT: %pattern_type.a07: type = pattern_type %J_where.type [concrete]
  447. // CHECK:STDOUT: %Alphabetical.type: type = fn_type @Alphabetical [concrete]
  448. // CHECK:STDOUT: %Alphabetical: %Alphabetical.type = struct_value () [concrete]
  449. // CHECK:STDOUT: %N: %J_where.type = bind_symbolic_name N, 0 [symbolic]
  450. // CHECK:STDOUT: %Reversed.type: type = fn_type @Reversed [concrete]
  451. // CHECK:STDOUT: %Reversed: %Reversed.type = struct_value () [concrete]
  452. // CHECK:STDOUT: }
  453. // CHECK:STDOUT:
  454. // CHECK:STDOUT: imports {
  455. // CHECK:STDOUT: }
  456. // CHECK:STDOUT:
  457. // CHECK:STDOUT: file {
  458. // CHECK:STDOUT: %Alphabetical.decl: %Alphabetical.type = fn_decl @Alphabetical [concrete = constants.%Alphabetical] {
  459. // CHECK:STDOUT: %M.patt: %pattern_type.a07 = symbolic_binding_pattern M, 0 [concrete]
  460. // CHECK:STDOUT: } {
  461. // CHECK:STDOUT: %.loc10_23.1: type = splice_block %.loc10_23.2 [concrete = constants.%J_where.type] {
  462. // CHECK:STDOUT: <elided>
  463. // CHECK:STDOUT: %J.ref: type = name_ref J, file.%J.decl [concrete = constants.%J.type]
  464. // CHECK:STDOUT: <elided>
  465. // CHECK:STDOUT: %.Self.ref.loc10_29: %J.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.e7c]
  466. // CHECK:STDOUT: %K.ref: %J.assoc_type = name_ref K, @K.%assoc0 [concrete = constants.%assoc0]
  467. // CHECK:STDOUT: %.Self.as_type.loc10_29: type = facet_access_type %.Self.ref.loc10_29 [symbolic_self = constants.%.Self.binding.as_type]
  468. // CHECK:STDOUT: %.loc10_29: type = converted %.Self.ref.loc10_29, %.Self.as_type.loc10_29 [symbolic_self = constants.%.Self.binding.as_type]
  469. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access constants.%J.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
  470. // CHECK:STDOUT: %.loc10_35.1: %empty_tuple.type = tuple_literal ()
  471. // CHECK:STDOUT: %.loc10_35.2: type = converted %.loc10_35.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  472. // CHECK:STDOUT: %.Self.ref.loc10_41: %J.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.e7c]
  473. // CHECK:STDOUT: %L.ref: %J.assoc_type = name_ref L, @L.%assoc1 [concrete = constants.%assoc1]
  474. // CHECK:STDOUT: %.Self.as_type.loc10_41: type = facet_access_type %.Self.ref.loc10_41 [symbolic_self = constants.%.Self.binding.as_type]
  475. // CHECK:STDOUT: %.loc10_41: type = converted %.Self.ref.loc10_41, %.Self.as_type.loc10_41 [symbolic_self = constants.%.Self.binding.as_type]
  476. // CHECK:STDOUT: %impl.elem1: type = impl_witness_access constants.%J.lookup_impl_witness, element1 [symbolic_self = constants.%impl.elem1]
  477. // CHECK:STDOUT: %Bool.call: init type = call constants.%Bool() [concrete = bool]
  478. // CHECK:STDOUT: %.loc10_46.1: type = value_of_initializer %Bool.call [concrete = bool]
  479. // CHECK:STDOUT: %.loc10_46.2: type = converted %Bool.call, %.loc10_46.1 [concrete = bool]
  480. // CHECK:STDOUT: %.loc10_23.2: type = where_expr %.Self.2 [concrete = constants.%J_where.type] {
  481. // CHECK:STDOUT: requirement_base_facet_type constants.%J.type
  482. // CHECK:STDOUT: requirement_rewrite %impl.elem0, %.loc10_35.2
  483. // CHECK:STDOUT: requirement_rewrite %impl.elem1, %.loc10_46.2
  484. // CHECK:STDOUT: }
  485. // CHECK:STDOUT: }
  486. // CHECK:STDOUT: %M.loc10_17.2: %J_where.type = bind_symbolic_name M, 0 [symbolic = %M.loc10_17.1 (constants.%M)]
  487. // CHECK:STDOUT: }
  488. // CHECK:STDOUT: %Reversed.decl: %Reversed.type = fn_decl @Reversed [concrete = constants.%Reversed] {
  489. // CHECK:STDOUT: %N.patt: %pattern_type.a07 = symbolic_binding_pattern N, 0 [concrete]
  490. // CHECK:STDOUT: } {
  491. // CHECK:STDOUT: %.loc12_19.1: type = splice_block %.loc12_19.2 [concrete = constants.%J_where.type] {
  492. // CHECK:STDOUT: <elided>
  493. // CHECK:STDOUT: %J.ref: type = name_ref J, file.%J.decl [concrete = constants.%J.type]
  494. // CHECK:STDOUT: <elided>
  495. // CHECK:STDOUT: %.Self.ref.loc12_25: %J.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.e7c]
  496. // CHECK:STDOUT: %L.ref: %J.assoc_type = name_ref L, @L.%assoc1 [concrete = constants.%assoc1]
  497. // CHECK:STDOUT: %.Self.as_type.loc12_25: type = facet_access_type %.Self.ref.loc12_25 [symbolic_self = constants.%.Self.binding.as_type]
  498. // CHECK:STDOUT: %.loc12_25: type = converted %.Self.ref.loc12_25, %.Self.as_type.loc12_25 [symbolic_self = constants.%.Self.binding.as_type]
  499. // CHECK:STDOUT: %impl.elem1: type = impl_witness_access constants.%J.lookup_impl_witness, element1 [symbolic_self = constants.%impl.elem1]
  500. // CHECK:STDOUT: %Bool.call: init type = call constants.%Bool() [concrete = bool]
  501. // CHECK:STDOUT: %.loc12_30.1: type = value_of_initializer %Bool.call [concrete = bool]
  502. // CHECK:STDOUT: %.loc12_30.2: type = converted %Bool.call, %.loc12_30.1 [concrete = bool]
  503. // CHECK:STDOUT: %.Self.ref.loc12_39: %J.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.e7c]
  504. // CHECK:STDOUT: %K.ref: %J.assoc_type = name_ref K, @K.%assoc0 [concrete = constants.%assoc0]
  505. // CHECK:STDOUT: %.Self.as_type.loc12_39: type = facet_access_type %.Self.ref.loc12_39 [symbolic_self = constants.%.Self.binding.as_type]
  506. // CHECK:STDOUT: %.loc12_39: type = converted %.Self.ref.loc12_39, %.Self.as_type.loc12_39 [symbolic_self = constants.%.Self.binding.as_type]
  507. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access constants.%J.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
  508. // CHECK:STDOUT: %.loc12_45.1: %empty_tuple.type = tuple_literal ()
  509. // CHECK:STDOUT: %.loc12_45.2: type = converted %.loc12_45.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  510. // CHECK:STDOUT: %.loc12_19.2: type = where_expr %.Self.2 [concrete = constants.%J_where.type] {
  511. // CHECK:STDOUT: requirement_base_facet_type constants.%J.type
  512. // CHECK:STDOUT: requirement_rewrite %impl.elem1, %.loc12_30.2
  513. // CHECK:STDOUT: requirement_rewrite %impl.elem0, %.loc12_45.2
  514. // CHECK:STDOUT: }
  515. // CHECK:STDOUT: }
  516. // CHECK:STDOUT: %N.loc12_13.2: %J_where.type = bind_symbolic_name N, 0 [symbolic = %N.loc12_13.1 (constants.%N)]
  517. // CHECK:STDOUT: }
  518. // CHECK:STDOUT: }
  519. // CHECK:STDOUT:
  520. // CHECK:STDOUT: generic fn @Alphabetical(%M.loc10_17.2: %J_where.type) {
  521. // CHECK:STDOUT: %M.loc10_17.1: %J_where.type = bind_symbolic_name M, 0 [symbolic = %M.loc10_17.1 (constants.%M)]
  522. // CHECK:STDOUT:
  523. // CHECK:STDOUT: !definition:
  524. // CHECK:STDOUT:
  525. // CHECK:STDOUT: fn() {
  526. // CHECK:STDOUT: !entry:
  527. // CHECK:STDOUT: return
  528. // CHECK:STDOUT: }
  529. // CHECK:STDOUT: }
  530. // CHECK:STDOUT:
  531. // CHECK:STDOUT: generic fn @Reversed(%N.loc12_13.2: %J_where.type) {
  532. // CHECK:STDOUT: %N.loc12_13.1: %J_where.type = bind_symbolic_name N, 0 [symbolic = %N.loc12_13.1 (constants.%N)]
  533. // CHECK:STDOUT:
  534. // CHECK:STDOUT: !definition:
  535. // CHECK:STDOUT: <elided>
  536. // CHECK:STDOUT:
  537. // CHECK:STDOUT: fn() {
  538. // CHECK:STDOUT: !entry:
  539. // CHECK:STDOUT: <elided>
  540. // CHECK:STDOUT: }
  541. // CHECK:STDOUT: }
  542. // CHECK:STDOUT:
  543. // CHECK:STDOUT: specific @Alphabetical(constants.%M) {
  544. // CHECK:STDOUT: %M.loc10_17.1 => constants.%M
  545. // CHECK:STDOUT: }
  546. // CHECK:STDOUT:
  547. // CHECK:STDOUT: specific @Reversed(constants.%N) {
  548. // CHECK:STDOUT: %N.loc12_13.1 => constants.%N
  549. // CHECK:STDOUT: }
  550. // CHECK:STDOUT:
  551. // CHECK:STDOUT: specific @Alphabetical(constants.%N) {
  552. // CHECK:STDOUT: %M.loc10_17.1 => constants.%N
  553. // CHECK:STDOUT:
  554. // CHECK:STDOUT: !definition:
  555. // CHECK:STDOUT: }
  556. // CHECK:STDOUT: